Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Attribute selectors are a very flexible way to manage styles for large-scale CSS because the attribute selectors will always have a <a href="http://www.w3.org/TR/css3-selectors/#specificity">specificity of <code>0-0-1-0</code></a>.</p> <p><code>[aria-*]</code> selectors are perfectly fine to use as styling hooks, and I also recommend using custom <code>[data-*]</code> attributes to fill in the gaps where you might need a one-off. Certainly class selectors should continue to be used, however you can do some very elegant style extensions with attribute selectors:</p> <pre><code>[data-foo] { color: red; } [data-foo="bar"] { color: blue; } [data-foo="fizz"] { color: green; } </code></pre> <p>Each of these selectors has the same specificity, and the cascade will allow the styles to be applied appropriately.</p> <p>You could create your own form of classes by using the <code>[attr~="value"]</code> selector if need be.</p> <p>Using the <a href="http://www.w3.org/TR/css3-selectors/#attribute-substrings">"attribute contains" selector</a> can be useful for <a href="http://zzzzbov.com/blag/classy-images-in-markdown">a technique that I call "classy images"</a></p> <hr> <p>One of the hidden benefits to using attributes over classes is a performance gain in JavaScript. Instead of having to check for the presence of a class on an element (which is remarkably easy to get wrong), browsers have supported <code>getAttribute</code>, <code>hasAttribute</code>, and <code>setAttribute</code> for a long time.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload