This appendix is a reference to the main CSS properties that you will be using to control the appearance of your documents.
For each property covered, you will first see a very brief description of the property and then an example of its usage. This is followed by two tables: the one on the left shows the possible values the property can take along with the first versions of Internet Explorer and Firefox to support these values, and the table on the right indicates whether the property can be inherited, what the default value for the property is, and which elements it applies to.
While browsers may support the inherit
value of many properties, if the browser is unable to set the property to some other value in the first place (perhaps because that value is not supported), then the inherit
value is of little use.
At the end of the appendix are units of measurement.
The font properties allow you to change the appearance of a typeface.
Allows you to set several font properties at the same time, separated by spaces. You can specify font-size
, line-height
, font-family
, font-style
, font-variant
, and font-weight
in this one property.
font {color:#ff0000; arial, verdana, sans-serif; 12pt;}
Allows you to specify the typefaces you want to use. Can take multiple values separated by commas, starting with your first preference, then your second choice, and ending with a generic font-family (serif
, sans-serif
, cursive
, fantasy
, or monospace
).
p {font-family:arial, verdana, sans-serif;}
Allows you to specify a size of font. The font-size
property has its own specific values:
Value | IE | FF | Inherited | Yes |
---|---|---|---|---|
[absolute size] | 3 | 1 | Default |
|
[relative size] | 4 | 1 | Applies to | All elements |
[percent] | 3 | 1 | ||
[length] | 3 | 1 | ||
| 8 | 1 |
Allows you to adjust the aspect value of a font, which is the ratio between the height of a lowercase letter x in the font and the height of the font.
{font-size-adjust:0.5;}
Value | IE | FF | Inherited | Yes |
---|---|---|---|---|
[number] | - | - | Default | Specific to font |
| - | - | Applies to | All elements |
| - | 1 |
Allows you to specify the width of the letters in a font (not the size between them).
Relative values: normal
, wider
, narrower
Fixed values: ultra-condensed
, extra-condensed
, condensed
, semi-condensed
, semi-expanded
, expanded
, extra-expanded
, ultra-expanded
p {font-family:courier; font-stretch:semi-condensed;}
Value | IE | FF | Inherited | Yes |
---|---|---|---|---|
[relative] | - | - | Default | Specific to font |
[fixed] | - | - | Applies to | All elements |
| - | 1 |
Applies styling to a font. If the specified version of the font is available, it will be used; otherwise, the browser will render it.
p {font-style:italic;}
Value | IE | FF | Inherited | Yes |
---|---|---|---|---|
| 3 | 1 | Default |
|
| 3 | 1 | Applies to | All elements |
| 4 | 1 | ||
| 8 | 1 |
Text properties change the appearance and layout of text in general (as opposed to the font).
Specifies the distance between letters as a unit of length.
p {letter-spacing:1em;}
Value | IE | FF | Inherited | Yes |
---|---|---|---|---|
[length] | 4 | 1 | Default |
|
| 4 | 1 | Applies to | All elements |
| 8 | 1 |
Specifies whether text is aligned left
, right
, center
, or justified
.
p {text-align:center}
Value | IE | FF | Inherited | Yes |
---|---|---|---|---|
| 3 | 1 | Default | Depends on user agent and element (usually |
| 3 | 1 | Applies to | All elements |
| 3 | 1 | ||
| 4 | 1 | ||
| 8 | 1 |
Specifies whether text should have an underline
, overline
, line-through
, or blink
appearance.
p {text-decoration:underline;}
Value | IE | FF | Inherited | No |
---|---|---|---|---|
| 3 | 1 | Default |
|
| 3 | 1 | Applies to | All elements |
| 4 | 1 | ||
| 3 | 1 | ||
| - | 1 | ||
| 8 | 1 |
Specifies the indentation in length or as a percentage of the parent element's width.
p {text-indent:3em;}
Value | IE | FF | Inherited | Yes |
---|---|---|---|---|
[length] | 4 | 1 | Default |
|
[percentage] | 4 | 1 | Applies to | Block elements |
| 8 | 1 |
Creates a drop shadow for the text. It should take three lengths; the first two specify X and Y coordinates for the offset of the drop shadow, while the third specifies a blur effect. This is then followed by a color, which can be a name or a hex value.
.dropShadow {text-shadow: 0.3em 0.3em 0.5em black}
Value | IE | FF | Inherited | No |
---|---|---|---|---|
[shadow effects] | - | 3.1b | Default |
|
| - | 3.1b | Applies to | All elements |
| - | 1 |
(Also supported in Safari 3, Chrome 2 and Opera 9.6 and higher.)
Specifies capitalization of text in an element:
none
: Removes inherited settings.
uppercase
: All characters are uppercase.
lowercase
: All characters are lowercase.
capitalize
: First letter of each word is capitalized.
p {text-transform:uppercase;}
Value | IE | FF | Inherited | Yes |
---|---|---|---|---|
| 4 | 1 | Default |
|
| 4 | 1 | Applies to | All elements |
| 4 | 1 | ||
| 4 | 1 | ||
| 8 | 1 |
This indicates how white space should be dealt with:
normal
: White space should be collapsed.
pre
: White space should be preserved.
nowrap
: Text should not be broken to a new line except with the <br />
element.
p {white-space:pre;}
Value | IE | FF | Inherited | Yes |
---|---|---|---|---|
| 5.5 | 1 | Default |
|
| 5.5 | 1 | Applies to | Block elements |
| 5.5 | 1 | ||
| 8 | 1 |
The following properties allow you to change the colors and backgrounds of both the page and other boxes.
This is shorthand for specifying background properties for color
, url
, repeat
, scroll
, and position
; separated by a space. By default, the background is transparent.
body {background: #efefef url("images/background.gif"); }
This specifies whether a background image should be fixed in one position or scroll along the page:
body {background-attachment:fixed; background-image: url("images/background.gif");}
Value | IE | FF | Inherited | No |
---|---|---|---|---|
| 4 | 1 | Default |
|
| 4 | 1 | Applies to | All elements |
| 8 | 1 |
Sets the color of the background. This can be a single color or two colors blended together. Colors can be specified as a color name, hex value, or RGB value. By default the box will be transparent.
body {background-color:#efefef;}
Value | IE | FF | Inherited | No |
---|---|---|---|---|
[color] | 4 | 1 | Default |
|
| 4 | 1 | Applies to | All elements |
| 8 | 1 |
This specifies an image to be used as a background, which by default will be tiled. Value is a URL for the image.
body {background-image: url("images/background.gif");}
Value | IE | FF | Inherited | No |
---|---|---|---|---|
[url] | 4 | 1 | Default |
|
| 4 | 1 | Applies to | All elements |
| 8 | 1 |
Specifies where a background image should be placed in the page, from the top-left corner. Values can be an absolute distance, percentage, or one of the keywords. If only one value is given, it is assumed to be horizontal.
Keywords available are: top
, bottom
, left
, right
, center
body {background-position:center; background-image: url("images/background.gif");}
Value | IE | FF | Inherited | No |
---|---|---|---|---|
[length - x y] | 4 | 1 | Default |
|
[percentage - x% y%] | 4 | 1 | Applies to | Block-level elements |
| 4 | 1 | ||
| 4 | 1 | ||
| 4 | 1 | ||
| 8 | 1 |
Specifies if a background image should be repeated, and if so in which directions. Values are repeat
to repeat horizontally and vertically, repeat-x
to just repeat horizontally, repeat-y
to just repeat vertically, and no-repeat
to prevent it from repeating.
Value | IE | FF | Inherited | No |
---|---|---|---|---|
| 4 | 1 | Default |
|
| 4 | 1 | Applies to | All elements |
| 4 | 1 | ||
| 4 | 1 | ||
| 8 | 1 |
Position of a background image to run horizontally across the page. Values are the same as forbackground-position
(default: top
).
The border properties allow you to control the appearance and size of a border around any box.
This is shorthand for specifying border-style
, border-width
, and border-color
properties.
Value | IE | FF | Inherited | No |
---|---|---|---|---|
[border-style] | 4 | 1 | Default |
|
[border-width] | 4 | 1 | Applies to | All elements |
[border-color] | 4 | 1 | ||
| 8 | 1 |
This specifies the style of line that should surround a block box.
div.page {border-style:solid;}
Value | IE | FF | Inherited | No |
---|---|---|---|---|
| 4 | 1 | Default |
|
| 5.5 | 1 | Applies to | All elements |
| 5.5 | 1 | ||
| 4 | 1 | ||
| 4 | 1 | ||
| 4 | 1 | ||
| 4 | 1 | ||
| 4 | 1 | ||
| 4 | 1 | ||
| - | - | ||
| 8 | 1 |
Specifies the width of a border line; can be a width or a keyword.
div.page {border-width:2px;}
Value | IE | FF | Inherited | No |
---|---|---|---|---|
[length] | 4 | 1 | Default |
|
| 4 | 1 | Applies to | All elements |
| 4 | 1 | ||
| 4 | 1 | ||
| 8 | 1 |
The dimensions properties allow you to specify the size that boxes should be.
Specifies the vertical height of a block element.
table {height:400px;}
Value | IE | FF | Inherited | No |
---|---|---|---|---|
| 4 | 1 | Default |
|
[length] | 4 | 1 | Applies to | Block-level elements |
[percentage] | 4 | 1 | ||
| 8 | 1 |
Specifies the horizontal width of an element.
td {width:150px;}
Value | IE | FF | Inherited | No |
---|---|---|---|---|
| 4 | 1 | Default |
|
[length] | 4 | 1 | Applies to | Block level elements |
[percentage] | 4 | 1 | ||
| 8 | 1 |
This specifies the height of a line of text. It is a way of controlling leading (space between multiple lines of text) because the line height may be more or less than the size of the font.
p {line-height:18px;}
Value | IE | FF | Inherited | Yes |
---|---|---|---|---|
| 3 | 1 | Default | Depends on browser |
[number] | 4 | 1 | Applies to | All elements |
[length] | 3 | 1 | ||
[percentage] | 3 | 1 | ||
| 8 | 1 |
This specifies the maximum height of a block-level element (same values as for height
).
td {max-height:200px;}
Value | IE | FF | Inherited | No |
---|---|---|---|---|
| 7 | 1 | Default |
|
[length] | 7 | 1 | Applies to | Block-level elements |
[percentage] | 7 | 1 | ||
| 8 | 1 |
This specifies the maximum width of a block-level element (same values as for width
).
td {max-width:400px;}
Value | IE | FF | Inherited | No |
---|---|---|---|---|
| 7 | 1 | Default |
|
[length] | 7 | 1 | Applies to | Block elements |
[percentage] | 7 | 1 | ||
| 8 | 1 |
Margin properties allow you to specify a margin around a box and therefore create a gap between elements' borders.
Padding properties set the distance between the border of an element and its content. They are important for adding white space to documents (in particular table cells).
List properties affect the presentation of bulleted, numbered, and definition lists.
This is shorthand allowing you to specify list-style-position
and list-style-type
.
ul {list-style: inside disc}
Value | IE | FF | Inherited | Yes |
---|---|---|---|---|
|
| 1 | Default | Depends on browser |
|
| 1 | Applies to | List elements |
|
| 1 | ||
| 8 | 1 |
This specifies whether the marker should be placed inside each item of a list or to the left of them.
ul {list-style-position:inside;}
Value | IE | FF | Inherited | Yes |
---|---|---|---|---|
| 4 | 1 | Default |
|
| 4 | 1 | Applies to | List elements |
| 8 | 1 |
This indicates the type of bullet or numbering that a bullet should use.
ul {list-style-type:circle;}
Value | IE | FF | Inherited | Yes |
---|---|---|---|---|
| 4 | 1 | Default |
|
|
| 1 | Applies to | List elements |
| 4 | 1 | ||
| 4 | 1 | ||
| 4 | 1 | ||
|
| - | ||
|
| 1 | ||
|
| 1 | ||
|
| 1 | ||
|
| 1 |
Additional numbered list styles are available in CSS, but unfortunately they are not supported in IE7, Netscape 7, or Firefox 2.
| Traditional Hebrew numbering |
---|---|
| Traditional Georgian numbering (an, ban, gan, . . . , he, tan, in, in-an, . . . ) |
| Traditional Armenian numbering |
| Plain ideographic numbers |
| (a, i, u, e, o, ka, ki, . . . ) |
| (A, I, U, E, O, KA, KI, . . . ) |
| (i, ro, ha, ni, ho, he, to, . . . ) |
| (I, RO, HA, NI, HO, HE, TO, . . . ) |
Positioning properties allow you to use CSS for positioning boxes on the page.
Specifies the positioning schema that should be used for an element. When an element is positioned, you also need to use the box-offset properties covered next (top
, left
, bottom
, and right
). Note that you should not use top
and bottom
or left
and right
together (if you do, top
and left
take priority).
absolute
can be fixed on the canvas in a specific position from its containing element (which is another absolutely positioned element); it will also move when the user scrolls the page.
static
will fix it on the page in the same place and keep it there even when the user scrolls.
relative
will be placed offset in relation to its normal position.
fixed
will fix it on the background of the page and not move when the user scrolls.
p.article{position:absolute; top:10px; left:20px;
Value | IE | FF | Inherited | No |
---|---|---|---|---|
| 4 | 1 | Default |
|
| 4 | 1 | Applies to | All elements |
| 4 | 1 | ||
| 7 | 1 | ||
| 8 | 1 |
This sets the horizontal position of an element from the left of the window or containing element.
Value | IE | FF | Inherited | No |
---|---|---|---|---|
| 4 | 1 | Default |
|
[length] | 4 | 1 | Applies to | Positioned elements |
[percentage — relative to parent's width] | 4 | 1 | ||
| 8 | 1 |
This sets the vertical position of an element from the bottom of the window or containing element.
Value | IE | FF | Inherited | No |
---|---|---|---|---|
| 5 | 1 | Default |
|
[length] | 5 | 1 | Applies to | Positioned elements |
[percentage — relative to parent's height] | 5 | 1 | ||
| 8 | 1 |
This sets the horizontal position of an element from the right of the window or containing element.
Value | IE | FF | Inherited | No |
---|---|---|---|---|
| 5 | 1 | Default |
|
[length] | 5 | 1 | Applies to | Positioned elements |
[percentage — relative to parent's width] | 5 | 1 | ||
| 8 | 1 |
This sets the vertical positioning of an inline element:
baseline
aligns element with base of parent.
middle
aligns midpoint of element with half the height of parent.
sub
makes element subscript.
super
makes element superscript.
text-top
aligns element with the top of parent element's font.
text-bottom
aligns element with the bottom of parent element's font.
top
aligns top of element with the top of tallest element on current line.
bottom
aligns element with the bottom of lowest element on the current line.
span.superscript {vertical-align:super;}
Controls which overlapping element appears to be on top. Positive and negative numbers are permitted.
p {position:absolute; top:10px; left:20px; z-index:3;}
Value | IE | FF | Inherited | No |
---|---|---|---|---|
| 4 | 1 | Default | Depends on position of element in XHTML source document |
[number] | 4 | 1 | ||
| 8 | 1 | Applies to | Positioned elements |
Controls which part of an element is visible. Parts outside the clip are not visible. If value is rect()
, it takes the following form:
rect([top] [right] [bottom] [left])
rect(25 100 100 25)
Value | IE | FF | Inherited | No |
---|---|---|---|---|
| 4 | 1 | Default |
|
| 4 | 1 | Applies to | Block elements |
| 8 | 1 |
Outlines act like borders, but do not take up any space — they sit on top of the canvas.
Shortcut for the outline-color
, outline-style
, and outline-width
properties:
outline {solid #ff0000 2px}
Note that outline-color
, outline-style
, and outline-width
take the same values as border-color
, border-style
, and border-width
.
Value | IE | FF | Inherited | No |
---|---|---|---|---|
| 8 | 1.5 | Default |
|
| 8 | 1.5 | Applies to | All elements |
| 8 | 1.5 | ||
| 8 | 1.5 |
Table properties allow you to affect the style of tables, rows, and cells.
This specifies the border model that the table should use (whether adjacent borders should be collapsed into one value or kept separate).
table {border-collapse:separate;}
Value | IE | FF | Inherited | Yes |
---|---|---|---|---|
| 5 | 1 | Default |
|
| 5 | 1 | Applies to | Table and inline elements |
| 8 | 1 |
This specifies the distance between adjacent cells' borders.
table {border-spacing:2px;}
Value | IE | FF | Inherited | Yes |
---|---|---|---|---|
[length] | 8 | 1 | Default |
|
| 8 | 1 | Applies to | Table and inline elements |
This indicates which side of a table a caption should be placed on.
caption {caption-side:bottom;}
Value | IE | FF | Inherited | Yes |
---|---|---|---|---|
| 8 | 1 | Default |
|
| 8 | 1 | Applies to |
|
| 8 | 1 | ||
| 8 | 1 | ||
| 8 | 1 |
Classification properties affect how the boxes in the box model are rendered.
Forces elements, which would normally wrap around an aligned element, to be displayed below it. Value indicates which side may not touch an aligned element.
p {clear:left;}
Value | IE | FF | Inherited | No |
---|---|---|---|---|
| 4 | 1 | Default |
|
| 4 | 1 | Applies to | All elements |
| 4 | 1 | ||
| 4 | 1 | ||
| 8 | 1 |
Specifies how an element is rendered, if at all. If set to none
the element is not rendered and it does not take up any space. This property can also force an inline element to be displayed as a block or vice versa.
span.important {display:block;}
Value | IE | FF | Inherited | Yes |
---|---|---|---|---|
| 4 | 1 | Default | inline |
| 5 | 1 | Applies to | All elements |
| 5 | 1 | ||
| 5 | 1 | ||
| 8 | 1 |
While the default value of this property is inline
, browsers tend to treat the element depending on its inherent display type. Block-level elements, such as headings and paragraphs, get treated as if the default were block
, whereas inline elements such as <i>
, <b>
, or <span>
get treated as inline
.
Subsequent elements should be wrapped to the left or right of the element, rather than below.
img.featuredItem {float:left;}
Value | IE | FF | Inherited | No |
---|---|---|---|---|
| 4 | 1 | Default |
|
| 4 | 1 | Applies to | All elements |
| 4 | 1 | ||
| 8 | 1 |
Internationalization properties affect how text is rendered in different languages.
3.15.143.207