Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Style attributes have very high specificity so they basically preclude using normal CSS files (they would mandate every line include !important)


This 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


If 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.


The parent is not talking about inheritance. They are talking about specificity.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: