I'm refactoring some html pages using css inheritance; trouble occurs when extending a style that extends from another style; properties from the base style are not picked up.
.font-base, .font-big, .font-bigger{
color: GREEN;
font-size: 11pt;
letter-spacing: 6pt;
}
.font-big {
font-size: 14pt;
}
.font-bigger, .font-italic {
font-size: 30pt;
}
.font-italic {
font-style: italic;
}
I was expecting font-italic
to pick up color
and letter-spacing
styles from font-base
, the base selector, but after reading this, css inheritance is not OO inheritance, so I'm assuming this is the expected behavior?
In the above example, however, font-italic
picks up styling from its peer selector, font-bigger
, which helps to avoid redundant styling, but I suspect this could get ugly real quick with multiple levels of inheritance.
Questions
Is it bad practice to repeatedly inherit class selectors? I'm asking because I don't do much CSS, and I want to be in accordance with good conventions.
The bonus question goes back to my original problem, is there a way to inherit styling that works like OO inheritance? I'm guessing SASS and LESS fall into that category?