css - Headings should only be defined once -


just ran decent amount of css through csslint, check errors. 80% of warnings defining same header element more once. wondering best way clean these kind of styles be...

h4 {     color: red; }  .archive h4 {     color: green; } 

keeping in mind i'm using h1 - h6 styles elsewhere in design.

would better use classes , inherit styles mix-ins (i'm using stylus)?

h4 {     color: red; }  .archive-header {     color: green; } 

while i'm @ it, why csslint warn against this? there performance hits?

  1. to around it, sure... you're solution should work fine.
  2. css lint warns against because shouldn't style same headers differently. here's little excerpt article talking more subject:

    when styling headings (or anything) want 3 big goals met:

    1. dry – not repeat yourself. want set headings once , never (ok, rarely!) repeat font styles or selectors. make our site easier maintain.
    2. predictable – heading should same no matter on page placed. make creating new pages , content easier.
    3. keep specificity low , selectors simple possible. performance , keep site growing more , more tangled on time.
  3. no performance hits. if anything, might better use class name instead of tag. solution proposed textbook recommendation of how make website faster google.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -