HTML and CSS Reference
In-Depth Information
of elements between the ancestor and descendant does not matter. As
a result, the following selector will match all elements inside the docu-
ment body:
body * {}
The child selector describes an element (F) that is the child (or direct
descendant) of another element (E).
ul > li { font-family: san-serif; }
ol > li { font-family: monospace; }
Here, list items that are direct children of an unordered list tag will be
in a sans-serif font, and those that are direct children of an ordered list
will be fixed-width.
The adjacent sibling combinatory matches elements (F) that come
directly after other elements (E) and share the same parent element.
h1 + p { font-size: 1.2em }
This example will select all paragraphs that come directly after an
<h1>
tag and apply an increased font size.
With this selector, the element (F) is selected if it appears at some point
after its sibling element (E).