Type, Class, ID, and Universal selectors
p { color: red }
.example { color: red }
#example { color: red }
* { color: red }
Descendant selectors
SelectorA SelectorB ![]()
![]()
![]()
When the two selectors are separated by a space, the style is applied only to the SelectorB of descendant of the SelectorA.
p strong { color: red; }

In this example, the style is applied only to STRONG element of descendant of P element.
Child selectors
SelectorA > SelectorB ![]()
![]()
When the two selectors are separated by a ">", the style is applied only to the SelectorB of child of the SelectorA.
p > strong { color: red; }

In this example, the style is applied only to STRONG element of child of P element.
Example page![]()
(Not supported in MSIE)
Adjacent sibling selectors
SelectorA + SelectorB ![]()
![]()
When the two selectors are separated by a "+", the style is applied only to the SelectorB that immediately follows the SelectorA. (The SelectorA and SelectorB share the same parent.)
h2 + p { color: red; }

In this example, the style is applied only to P element that immediately follows H2 element.
Example page![]()
(Not supported in MSIE)