HTML and CSS Reference
In-Depth Information
Pseudo-Class Selectors
Pseudo-classes are considered classes in the specificity calculation.
# of
# of
# of
Selector
IDs
Classes
Elements
In English
div#content
The contents of the
p
that is
1,
1,
2
p:first-child
the first child of a
div
with the ID of
content
a:visited em
The contents of any
em
contained
within an
a
that is in the visited state
0,
1,
2
div#sidebar p:hover
The contents of any
p
in the hover
state that is contained within a
div
with the ID of
sidebar
1,
1,
2
input:focus
The contents of any
input
field when
it has the focus of the browser
0,
1,
1
Pseudo-Elements
Pseudo-elements are considered elements in the specificity calculation.
# of
# of
# of
Selector
IDs
Classes
Elements
In English
dl.wines
The first line of any
dd
contained
0,
1,
3
dd:first-line
within a
dl
with a class of
wines
ul li#description
The first letter of any
p
contained
1,
0,
4
p:first-letter
within an
li
with the ID of
description
, contained within
a
ul
ol#priority li:before
Inserts content before any
li
contained within an
ol
with
the ID of
priority
1,
0,
3
div#main p.
Inserts content after any
p
with
1,
1,
3
item-footer:after
a class of
item-footer
contained
within a
div
with the ID of
main