3. – http://cssguidelin.es/
Harry Roberts
CSS is not a pretty language.
While it is simple to learn and get started with, it soon
becomes problematic at any reasonable scale.
26. Principles
• Separate Container and Content
• break the dependency between the
container module and the content
objects it contains.
27. Some Guidelines
for OOCSS
• Avoid the descendent selector (i.e. don’t
use .sidebar h3)
• Avoid IDs as styling hooks
• Avoid attaching classes to elements in your
stylesheet (i.e. don’t do div.header or h1.title)
• Except in some rare cases, avoid using !
important
50. Why CLASSES?
• 3.2.5.7 The class attribute
• https://html.spec.whatwg.org/multipage/dom.html#classes
• The attribute, if specified, must have a value that is a set of
space-separated tokens representing the various classes that
the element belongs to.
• There are no additional restrictions on the tokens authors
can use in the class attribute, but authors are encouraged to
use values that describe the nature of the content, rather than
values that describe the desired presentation of the content.
51. Why CLASSES?
• Therefore,
• BEM
• .primary-nav__sub-nav—current
• Utilities
• .u-textTruncate
• left
• clearfix
• Javascript hook
• .js-whatevs
GLOBAL NAMESPACE
52. ~=
Attribute is within
Space Separated List
<div class='a b c'>
.a { ... }
.b { ... }
.c { ... }
[class~='a'] { ... }
[class~='b'] { ... }
[class~='c'] { ... }