3 ms·
per the slideshow, 3 "best practice myths": - don't add any extra elements - don't add classes - use descendent selectors exclusively the second two i've ne
by catshirt 16y ago
per the slideshow, 3 "best practice myths":
- don't add any extra elements
- don't add classes
- use descendent selectors exclusively
the second two i've never heard in my life, and i'm quite sure the first is not a myth.
- mokkos 16y agoshe's referring to "classitis": http://www.sitekin.com/blogdetail/avoid_CSS_Classitis http://www.sitekin.com/blogdetail/avoid_CSS_Classitis in that example, classitis is when you give a class "item" to every li element, the using .item to style it while the alternate way to do it is using the descendent selector (.parentcontainer li). Nicole Sullivan is saying this can lead to specificity war over time.
- T-R 16y agoBy "don't add classes", she means "avoid using redundant or non-semantic classes in the HTML", which makes sense, because unless you're generating the HTML on request or compensating with jQuery (and therefore adding another dependency to your layout), the repetition becomes a maintenance issue. Avoiding non-semantic elements and non-semantic classes, however, restricts you to using descendant selectors (and multiple declarations), which, as she points out, creates another maintenance issue in the form inheritance conflict resolution (specificity).