HTML and CSS Reference
In-Depth Information
Selector
Description
Example
Defined In
Selects the elements
that are the default
among a set of similar
elements
CSS3
:default
:default {background-color: red;}
/* sets the background color of a
default button like a submit to
red */
:disabled
Selects the elements
that are currently
disabled
input:disabled {background-color:
gray;}
/* sets the background color to
gray on disabled input elements */
CSS3
Selects an element
that has no children
CSS3
:empty
div:empty {display: none;}
/* hides the div if it has no
children */
Selects the elements
that are currently
enabled
CSS3
:enabled
input:enabled {background-color:
white;}
/* sets the background color to
white on enabled input elements */
:first-child
Selects the element
only if the element is
the first child of its
parent
p:first-child { color: red;}
/* sets the font color to red for
all of the p tags that are the
first child of their parent */
CSS2
Selects the first letter
of an element
CSS1
:first-letter
p:first-letter {font-size: larger;}
/* makes the first letter of a
paragraph larger */
Same as :first-
letter ; changed
under CSS3 to make
pseudo-elements
obvious
CSS3
::first-letter
p::first-letter {font-size:
larger;}
/* makes the first letter of a
paragraph larger */
Selects the first line of
an element
CSS1
:first-line
p:first-line {color: red;}
/* makes the first lines
of paragraph red */
::first-line
Same as :first-
line ; changed under
CSS3 to make pseudo-
elements obvious
p::first-line {color: red;}
/* makes the first lines
of paragraph red */
CSS3
Selects the element
that is the first child
of its parent that is of
its type
CSS3
:first-of-type
strong:first-of-type {font-size:
bigger;}
/* sets the font size bigger on the
first strong tag of its parent */
T ABLE 5-5 CSS Selectors
 
Search WWH ::




Custom Search