3 ms·
Style attributes have very high specificity so they basically preclude using normal CSS files (they would mandate every line include !important)
by cosmotic 6y ago
Style attributes have very high specificity so they basically preclude using normal CSS files (they would mandate every line include !important)
- gitgud 6y agoThis is misleading, !important is not required to use inline styles. They still cascade normally like CSS classes... see this example: <div style="color: red"> <p>red text</p> <p>red text</p> <p style="color: blue">blue text</p> </div> Ironically, it's actually complex CSS classes and long selectors that produce high specificity, which then requires even more specificity to override and eventually the dreaded !important
- SahAssar 6y agoThe parent is not talking about inheritance. They are talking about specificity.
- cosmotic 6y agoIf an element has a style attribute that sets the color, it will override every single CSS/Style-element style that also sets the color, unless the CSS/Style-element style also includes an !important.