HTML and CSS Reference
In-Depth Information
Descendant, Child, and Adjacent Sibling Selectors
# of
# of
# of
Selector
IDs
Classes
Elements
In English
h1 em
Any em contained within any h1
0,
0,
2
p > img
Any img that is the child of a p
0,
0,
2
div#sidebar h3 + p
Any p that immediately follows
an h3 contained within a div with
the ID of sidebar
1,
0,
3
div#header ul#nav
Any anchor ( a ) contained
2,
1,
4
li.current a
within an li with a class of
current , which is a descendant of
a ul with the ID of nav , contained
within a div with the ID of header
Attribute Selectors
Attribute selectors are considered classes in the specificity calculation, even when the targeted
attribute is an ID.
# of
# of
# of
Selector
IDs
Classes
Elements
In English
input[type=text]
The contents of any input
with a value of text in the
type attribute
0,
1,
1
a[href~=".org"]
The contents of any a with
an href value that includes
.org
0,
1,
1
dl#address dd h3[title]
The contents of any h3 that
has any value set in its title
attribute, and that is con-
tained within a dd that is
a descendant of a dl with
the ID of address
1,
0,
3
Search WWH ::




Custom Search