In SCSS, you can inherit properties from one selector to another using extensions (@extend
). This allows avoiding code
duplication and maintaining style consistency.
Example of inheritance in SCSS:
%message-shared { border: 1px solid #ccc; padding: 10px; color: #333; } .message { @extend %message-shared; background-color: #f0f0f0; } .error { @extend %message-shared; background-color: #fdd; border-color: #f00; }
Benefits:
- Reduction of code redundancy: Less code to write and maintain.
- Style consistency: Styling is more consistent and easier to manage.