Classifying Class Names

Classifying Class Names

Slides for my talk for CSS Summit 2015 on naming CSS stuff.

Ethan Muller

July 08, 2015

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

74 slides
  1. 8 Paraphrase from the intro to CSS on davesite.com* Imagine

    you've just designed a two hundred page web site, but at the last minute your client decides the font should be serif instead of sans-serif… *Still not a recommended resource
  2. 25 The Best Classes • Don’t need to change •

    Are reusable • Change easily when they inevitably change
  3. 43 “… Class names cannot be ‘unsemantic’. Whatever names are

    being used: they have meaning, they have purpose.” Nicolas Gallagher, About HTML semantics and front-end architecture http://bit.ly/ccn-class-name-semantics
  4. 50 CSS Zen Garden was created to showcase CSS to

    convince people to use CSS http://bit.ly/ccn-zen-garden
  5. 51 CSS Zen Garden wasn’t created as an example of

    how to build maintainable websites
  6. 60 Content-based classes work better on small sites* Presentational classes

    work better on large sites* * Many, many caveats apply
  7. 66 4. If there isn’t a clear reason, try to

    name it after common patterns in UI
  8. 67 5. If there isn’t a clear UI-related name, gauge

    how reusable you think your style block is
  9. 68 6. If it feels reusable, and it doesn’t feel

    like a bad idea, use a presentational class name
  10. 69 7. If it you don’t see yourself reusing these

    styles, use a content-based class name
  11. 72 Further Reading Challenging CSS Best Practices by Thierry Koblentz

    http://bit.ly/ccn-presentation-post Cargo Cult CSS by Ben Darlow http://bit.ly/ccn-content-based-post Classy Values by Jeremy Keith http://bit.ly/ccn-classy-values
  12. 73 Further Reading About HTML semantics and front-end architecture by

    Nicolas Gallagher http://bit.ly/ccn-class-name-semantics Why the Web Doesn't Need Another CSS Zen Garden (video) by David Shea http://bit.ly/ccn-zen-garden

More Decks by Ethan Muller

Other Decks in Programming