@include vs @extend in SASS Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article Like Report @include keyword is used to include the code written in a mixin block. @mixin is used to group css code that has to be reused a no of times. Whereas the @extend is used in SASS to inherit(share) the properties from another css selector. @extend is most useful when the elements are almost same or identical. The main difference between the two is in their compiled CSS file. @include example SCSS file: css @mixin text { color: black; font-size: 30px; font-weight: bold; } .hello{ @include text; } .world{ @include text; } Mixin duplicates the styles over all classes in the CSS. Compiles CSS file: .hello{ color: black; font-size: 30px; font-weight: bold; } .world{ color: black; font-size: 30px; font-weight: bold; } Mixin can also accept parameters if required, whereas this is not possible with extend. for more details of @mixin visit here @extend example: Here in this example, the two buttons will share the general properties for a button but they differ in background color only so using extend in cases like these where the elements are almost the same and only differ some properties using @extend is a good idea. SCSS file: css %button-format { padding: 10px 20px; border-radius: 15px; color: black; } .toolbar-button { @extend %button-format; background-color: lightpink; &:hover { background-color: rgb(155, 106, 114); } } .status-bar-button { @extend %button-format; background-color: lightblue; &:hover { background-color: blue; } } compiled CSS file: .status-bar-button, .toolbar-button { padding: 10px 20px; border-radius: 15px; color: black; } .toolbar-button { background-color: lightpink; } .toolbar-button:hover { background-color: #9b6a72; } .status-bar-button { background-color: lightblue; } .status-bar-button:hover { background-color: blue; } Conclusion: SASS is a fantastic style sheet language and its both features @include and @extend both have pros and cons despite this, if used in the exact situation these can prove to be the best tools of SASS. Comment More infoAdvertise with us Next Article Include v/s Extend in Ruby S shirshak Follow Improve Article Tags : Technical Scripter Web Technologies CSS Technical Scripter 2019 SASS +1 More Similar Reads Include v/s Extend in Ruby Include is used to importing module code. Ruby will throw an error when we try to access the methods of import module with the class directly because it gets imported as a subclass for the superclass. So, the only way is to access it through the instance of the class. Extend is also used to importin 2 min read Sass @extend Rule The sass @extend rule can be used when it is necessary for a class to have the styles of another class, along with its own specific styles. This rule tells Sass that one selector should inherit the class from another selector.Syntax:@extend <selector>Example: This example shows the use of the 3 min read SASS @mixin and @include SASS Mixins are used for writing reusable styles, similar to functions in programming languages. You can define a block of styles inside a mixin and reuse it across your project. Mixins can also accept arguments, which allows for dynamic values, making your code flexible and easier to maintain.Mixin 2 min read Less.js Extend LESS.js is one of the most popular CSS preprocessor languages because of its many features like mixins, imports, variables and, so on, which help to reduce the complexity of CSS code. One such important and useful feature of LESS is the @extend directive. In this article, we will see the basic usage 3 min read Less.js Extend Syntax & Inside Ruleset LESS.js is one of the most popular CSS preprocessor languages because of its many features like mixins, imports, variables, and, so on, which help to reduce the complexity of CSS code. One such important and useful feature of LESS is the @extend directive. In this article, we will see the basic usa 2 min read What is a @extend directive in SASS ? Sass is short for Syntactically Awesome Style Sheet. It is an upgrade to Cascading Style Sheets (CSS) and is one of the popular pre-processors available for writing CSS. The @extend is a keyword in Sass that allows one to share a set of CSS properties from one selector to another. This is useful for 3 min read Like