
SELECTOR TYPES
Name Info Example
Universal Any element * { font: 10px Arial; }
Type Any element of
that type
h1 { text-decoration:
underline; }
Grouping Multiple
elements of
different types
h1, h2, h3 { font-family:
Verdana; }
Class Multiple
elements of
different types
when you don’t
want to affect
all instances of
that type
.sampleclass { text-
decoration: underline; }
Id A single
element type
when you don’t
want to affect
all instances of
that type
#sampleid { text-
decoration: underline; }
Descendant An element that
is below (in the
document tree)
another
element—no
matter how
many levels
below
#gallery h1 { text-
decoration: underline; }
Child An element that
is directly below
(in the
document tree)
another
element
#title > p { font-weight:
bold; }
Adjacent
Sibling
All elements
that share the
same parent
and elements
are in the same
immediate
sequence
h1 + p { font-style:
italic; }
Attribute An element with
that matches
the attribute
listed
E[selected] - att whatever
the value
E[att="val"] - att with a
specific value
E[rel~="next"] - att with
a value is a whitespace
separated list
*[lang|="en"] - att value
either being exactly "val"
or beginning with "val"
immediately followed by
"-"
E[att^="val"] - att value
that begins with the prefix
"val"
E[att$="val"] - att value
that end with the suffix
"val"
E[att*="val"] - att value
contains at least one
instance of the substring
"val"
General
Sibling
All elements
that share the
same parent
and elements
are in the same
sequence (not
necessarily
immediate)
h1 ~ p { font-style:
italic; }
UNITS
ABSOLUTE MEASUREMENT
% percentage
cm centimeter
in inch
mm millimeter
pc pica (1p = 12 points)
pt point (1pt = 1/72 inch)
RELATIVE MEASUREMENT
ch width of the "0" glyph found in
the font for the font size used to
render
em 1em = current font size of
current element
ex x-height of the element's font
gd the grid defined by 'layout-grid'
px pixel of the viewing device
rem the font size of the root element
vh the viewport's height
vw the viewport's width
vm viewport's height or width,
whichever is smaller of the two
ANGLES
deg degrees
grad grads
rad radians
turn turns
TIME
ms milli-seconds
s seconds
Hz hertz
kHz kilo-hertz
COLORS
color name red, blue, green, dark green
rgb(x,y,z) red = rgb(255,0,0)
rgb(x%,y%,z%) red = rgb(100%,0,0)
#rrggbb red = #ff0000 (or shorthand =
#f00)
FREQUENCY
hsl(hue, saturation,
lightness)
red = hsl(0, 100%, 50%)
hsla(hue, saturation,
lightness, alpha)
red = hsl(0, 100%, 50%)
rgba(x,y,z, alpha) red = rgba(255,0,0)
flavor An accent color (typically chosen
by the user) to customize the
user interface of the user agent
itsel
currentColor computed value of the
'currentColor' keyword is the
computed value of the 'color'
property
PSEUDO-CLASS
:active an activated element
:focus an element while the
element has focus
:visited a visited link
:hover an element when you mouse
over it
:link an unvisited link
:disabled an element while the
element is disabled
:enabled an element while the
element is enabled
:checked an element (form element
control) that is checked
:selection an element that is currently
selected of highlighted by
the user
:lang Allows the author to specify
a language to use in a
specified element
:nth-child(n) an element that is the n-th
sibling
:nth-last-child(n) an element that is the n-th
sibling counting from the
last sibling
:first-child an element that is the first
sibling
:last-child an element that is the last
sibling
:only-child an element that is the only
child
:nth-of-type(n) an element that is the n-th
sibling of its type.
:nth-last-of-type(n) an element that is the n-th
sibling of its type counting
from the last sibling
:last-of-type an element that is the first
sibling of its type
:first-of-type an element that is the last
sibling of its type
:only-of-type an element that is the only
child of that type
:empty an element that has no
children
:root root element within the
document
:not(x) an element not represented
by the argument ‘x’
:target a target element as specified
by a target in a URI
PSEUDO-ELEMENT
::first-letter Adds special style to the first
letter of a text
::first-line Adds special style to the first
line of a text
::before Inserts some content before
an element
::after Inserts some content after an
element
Cascading Style Sheets (CSS 3)
©2010 copyright crazyfrom.com
http://www.crazyfrom.com
CSS