Skip to article frontmatterSkip to article content
tools = require('../js/tools'); tools.init()
Loading...

selectors are very powerful

generally speaking, selectors can be combined to create more and more selective ones; for example

selecting X under Y

div p
matches all <p> elements that are below a <div> element at any depth

div>p
matches all <p> elements that are an immediate child of <div> element

Loading...

selecting X as a sibling of Y

div + p
matches all <p> elements that are immediate right sibling of a <div> element

div ~ p
matches all <p> elements that are some right sibling of a <div> element

Loading...

pseudo-class selectors

:hover pseudo-class

a first, not-quite-working example (at least on Chrome)

Loading...

to get it right, we can use the other pseudo-class :link
that is set only on <a> tags that have a href= attribute

Loading...

rank of element amongst its siblings

nth-child() example

Loading...

pseudo-class selectors (continued)

attribute selectors (advanced)