Appendix C. CSS Properties

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.

Font Properties

The font properties allow you to change the appearance of a typeface.

font

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;}

Value

IE

FF

Inherited

Yes

[font-family]

3

1

Default

n/a

[font-size]

3

1

Applies to

All elements

[font-style]

3

1

  

[font-variant]

4

1

  

[font-weight]

3

1

  

[line-height]

3

1

  

inherit

8

1

  

font-family

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;}

Value

IE

FF

Inherited

Yes

[generic family]

3

1

Default

Set by browser

[specific family]

3

1

Applies to

All elements

inherit

8

1

  

font-size

Allows you to specify a size of font. The font-size property has its own specific values:

  • Absolute sizes: xx-small, x-small, small, medium, large, x-large, xx-large

  • Relative sizes: larger, smaller

  • Percentage: Percentage of the parent font

  • Length: A unit of measurement (as described at end of the appendix)

Value

IE

FF

Inherited

Yes

[absolute size]

3

1

Default

medium

[relative size]

4

1

Applies to

All elements

[percent]

3

1

  

[length]

3

1

  

inherit

8

1

  

font-size-adjust

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

none

-

-

Applies to

All elements

inherit

-

1

  

font-stretch

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

inherit

-

1

  

font-style

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

normal

3

1

Default

normal

italic

3

1

Applies to

All elements

oblique

4

1

  

inherit

8

1

  

font-variant

Creates capital letters that are the same size as normal lowercase letters.

Value

IE

FF

Inherited

Yes

normal

4

1

Default

normal

small-caps

4

1

Applies to

All elements

inherit

8

1

  

font-weight

Specifies the thickness of the text — its !"boldness." !

  • Absolute values: normal, bold

  • Relative values: bolder, lighter

  • Numeric value: Between 0 and 100

p {font-weight:bold;}

Value

IE

FF

Inherited

Yes

[absolute]

3

1

Default

normal

[relative]

4

1

Applies to

All elements

[number 1-100]

4

1

  

inherit

8

1

  

Text Properties

Text properties change the appearance and layout of text in general (as opposed to the font).

letter-spacing

Specifies the distance between letters as a unit of length.

p {letter-spacing:1em;}

Value

IE

FF

Inherited

Yes

[length]

4

1

Default

normal

normal

4

1

Applies to

All elements

inherit

8

1

  

text-align

Specifies whether text is aligned left, right, center, or justified.

p {text-align:center}

Value

IE

FF

Inherited

Yes

left

3

1

Default

Depends on user agent and element (usually left except for <th> elements, which are center)

right

3

1

Applies to

All elements

center

3

1

  

justify

4

1

  

inherit

8

1

  

text-decoration

Specifies whether text should have an underline, overline, line-through, or blink appearance.

p {text-decoration:underline;}

Value

IE

FF

Inherited

No

none

3

1

Default

none

underline

3

1

Applies to

All elements

overline

4

1

  

line-through

3

1

  

blink

-

1

  

inherit

8

1

  

text-indent

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

0

[percentage]

4

1

Applies to

Block elements

inherit

8

1

  

text-shadow

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

none

none

-

3.1b

Applies to

All elements

inherit

-

1

  

(Also supported in Safari 3, Chrome 2 and Opera 9.6 and higher.)

text-transform

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

none

4

1

Default

none

uppercase

4

1

Applies to

All elements

lowercase

4

1

  

capitalize

4

1

  

inherit

8

1

  

white-space

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

normal

5.5

1

Default

normal

pre

5.5

1

Applies to

Block elements

nowrap

5.5

1

  

inherit

8

1

  

word-spacing

This specifies the gap between words:

p {word-spacing:2em;}

Value

IE

FF

Inherited

Yes

normal

6

1

Default

normal

[length]

6

1

Applies to

All elements

inherit

8

1

  

Color and Background Properties

The following properties allow you to change the colors and backgrounds of both the page and other boxes.

background

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"); }

Value

IE

FF

Inherited

No

[background-attachment]

4

1

Default

Not defined (by default background is transparent)

[background-color]

3

1

Applies to

All elements

[background-image]

3

1

  

[background-position]

4

1

  

[background-repeat]

3

1

  

inherit

-

1

  

background-attachment

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

fixed

4

1

Default

scroll

scroll

4

1

Applies to

All elements

inherit

8

1

  

background-color

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

transparent

transparent

4

1

Applies to

All elements

inherit

8

1

  

background-image

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

none

none

4

1

Applies to

All elements

inherit

8

1

  

background-position

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

top, left

[percentage - x% y%]

4

1

Applies to

Block-level elements

top

4

1

  

left

4

1

  

center

4

1

  

inherit

8

1

  

background-repeat

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

repeat

4

1

Default

none

repeat-x

4

1

Applies to

All elements

repeat-y

4

1

  

no-repeat

4

1

  

inherit

8

1

  

background-positionX

Position of a background image to run horizontally across the page. Values are the same as forbackground-position (default: top).

background-positionY

Position of a background image to run vertically down the page. Values are the same as for background-position (default: left).

Border properties

The border properties allow you to control the appearance and size of a border around any box.

border (border-bottom, border-left, border-top, border-right)

This is shorthand for specifying border-style, border-width, and border-color properties.

Value

IE

FF

Inherited

No

[border-style]

4

1

Default

none, medium, none

[border-width]

4

1

Applies to

All elements

[border-color]

4

1

  

inherit

8

1

  

border-style (border-bottom-style, border-left-style, border-top-style, border-right-style)

This specifies the style of line that should surround a block box.

div.page {border-style:solid;}

Value

IE

FF

Inherited

No

none

4

1

Default

none

dotted

5.5

1

Applies to

All elements

dashed

5.5

1

  

solid

4

1

  

double

4

1

  

groove

4

1

  

ridge

4

1

  

inset

4

1

  

outset

4

1

  

hidden

-

-

  

inherit

8

1

  

border-width (border-bottom-width, border-left-width, border-top-width, border-right-width)

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

medium

thin

4

1

Applies to

All elements

medium

4

1

  

thick

4

1

  

inherit

8

1

  

border-color (border-bottom-color, border-left-color, border-top-color, border-right-color)

Specifies the color of a border; values can be a color name, hex code, or RGB value.

table {border-color:#000000;}

Value

IE

FF

Inherited

No

[color value]

4

1

Default

none

inherit

8

1

Applies to

All elements

Dimensions

The dimensions properties allow you to specify the size that boxes should be.

height

Specifies the vertical height of a block element.

table {height:400px;}

Value

IE

FF

Inherited

No

auto

4

1

Default

auto

[length]

4

1

Applies to

Block-level elements

[percentage]

4

1

  

inherit

8

1

  

width

Specifies the horizontal width of an element.

td {width:150px;}

Value

IE

FF

Inherited

No

auto

4

1

Default

auto

[length]

4

1

Applies to

Block level elements

[percentage]

4

1

  

inherit

8

1

  

line-height

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

normal

3

1

Default

Depends on browser

[number]

4

1

Applies to

All elements

[length]

3

1

  

[percentage]

3

1

  

inherit

8

1

  

max-height

This specifies the maximum height of a block-level element (same values as for height).

td {max-height:200px;}

Value

IE

FF

Inherited

No

auto

7

1

Default

auto

[length]

7

1

Applies to

Block-level elements

[percentage]

7

1

  

inherit

8

1

  

max-width

This specifies the maximum width of a block-level element (same values as for width).

td {max-width:400px;}

Value

IE

FF

Inherited

No

auto

7

1

Default

auto

[length]

7

1

Applies to

Block elements

[percentage]

7

1

  

inherit

8

1

  

min-height

This specifies the minimum height of a block-level element (same values as for height).

td {min-height:100px;}

Value

IE

FF

Inherited

No

auto

7

1

Default

auto

[length]

7

1

Applies to

Block-level elements

[percentage]

7

1

  

inherit

8

1

  

min-width

This specifies the minimum width of a block-level element (same values as for width).

td {min-width:200px;}

Value

IE

FF

Inherited

No

auto

7

1

Default

auto

[length]

7

1

Applies to

Block elements

[percentage]

7

1

  

inherit

8

1

  

Margin Properties

Margin properties allow you to specify a margin around a box and therefore create a gap between elements' borders.

margin (margin-bottom, margin-left, margin-top, margin-right)

This specifies the width of a margin around a box.

p {margin:15px;}

Value

IE

FF

Inherited

No

auto

3

1

Default

0

[length]

3

1

Applies to

All elements

[percentage — relative to parent element]

3

1

  

inherit

8

1

  

Padding Properties

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).

padding (padding-bottom, padding-left, padding-right, padding-top)

This specifies the distance between an element's border and its content.

td {padding:20px;}

Value

IE

FF

Inherited

No

auto

4

1

Default

zero

[length]

4

1

Applies to

All elements

[percentage — relative to parent element]

4

1

  

inherit

8

1

  

List Properties

List properties affect the presentation of bulleted, numbered, and definition lists.

list-style

This is shorthand allowing you to specify list-style-position and list-style-type.

ul {list-style: inside disc}

Value

IE

FF

Inherited

Yes

<position>

4

1

Default

Depends on browser

<type>

4

1

Applies to

List elements

<image>

4

1

  

inherit

8

1

  

list-style-position

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

inside

4

1

Default

outside

outside

4

1

Applies to

List elements

inherit

8

1

  

list-style-type

This indicates the type of bullet or numbering that a bullet should use.

ul {list-style-type:circle;}

Value

IE

FF

Inherited

Yes

None

4

1

Default

disc

disc (default)

4

1

Applies to

List elements

circle

4

1

  

square

4

1

  

decimal

4

1

  

decimal-leading-zero

-

-

  

lower-alpha

4

1

  

upper-alpha

4

1

  

lower-roman

4

1

  

upper-roman

4

1

  

Additional numbered list styles are available in CSS, but unfortunately they are not supported in IE7, Netscape 7, or Firefox 2.

hebrew

Traditional Hebrew numbering

georgian

Traditional Georgian numbering (an, ban, gan, . . . , he, tan, in, in-an, . . . )

armenian

Traditional Armenian numbering

cjk-ideographic

Plain ideographic numbers

hiragana

(a, i, u, e, o, ka, ki, . . . )

katakana

(A, I, U, E, O, KA, KI, . . . )

hiragana-iroha

(i, ro, ha, ni, ho, he, to, . . . )

katakana-iroha

(I, RO, HA, NI, HO, HE, TO, . . . )

marker-offset

This specifies the space between a list item and its marker.

ol {marker-offset:2em;}

Value

IE

FF

Inherited

No

[length]

7

1

Default

auto

auto

7

1

Applies to

Marker elements

inherit

8

1

  

Positioning Properties

Positioning properties allow you to use CSS for positioning boxes on the page.

position

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

absolute

4

1

Default

static

relative

4

1

Applies to

All elements

static

4

1

  

fixed

7

1

  

inherit

8

1

  

top

This sets the vertical position of an element from the top of the window or containing element.

Value

IE

FF

Inherited

No

auto

4

1

Default

auto

[length]

4

1

Applies to

Positioned elements

[percentage — relative to parent's height]

4

1

  

inherit

8

1

  

left

This sets the horizontal position of an element from the left of the window or containing element.

Value

IE

FF

Inherited

No

auto

4

1

Default

auto

[length]

4

1

Applies to

Positioned elements

[percentage — relative to parent's width]

4

1

  

inherit

8

1

  

bottom

This sets the vertical position of an element from the bottom of the window or containing element.

Value

IE

FF

Inherited

No

auto

5

1

Default

auto

[length]

5

1

Applies to

Positioned elements

[percentage — relative to parent's height]

5

1

  

inherit

8

1

  

right

This sets the horizontal position of an element from the right of the window or containing element.

Value

IE

FF

Inherited

No

auto

5

1

Default

auto

[length]

5

1

Applies to

Positioned elements

[percentage — relative to parent's width]

5

1

  

inherit

8

1

  

vertical-align

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;}

Value

IE

N

Inherited

No

baseline

4

1

Default

baseline

middle

4

1

Applies to

Inline elements

sub

4

1

  

super

4

1

  

text-top

4

1

  

text-bottom

4

1

  

top

4

1

  

bottom

4

1

  

[percentage relative to line height]

8

1

  

[length]

-

-

  

inherit

8

1

  

z-index

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

auto

4

1

Default

Depends on position of element in XHTML source document

[number]

4

1

  

inherit

8

1

Applies to

Positioned elements

clip

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

auto

4

1

Default

auto

rect

4

1

Applies to

Block elements

inherit

8

1

  

overflow

This specifies how a container element will display content that is too large for its containing element.

p {width:200px; height:200px; overflow:scroll;}

Value

IE

FF

Inherited

No

auto

4

1

Default

visible

hidden

4

1

Applies to

Block elements

visible

4

1

  

scroll

4

1

  

inherit

8

6

  

overflow-x

Same as overflow, but only for the horizontal x-axis. First supported in IE5.

overflow-y

Same as overflow, but only for the vertical y-axis. First supported in IE5.

Outline Properties

Outlines act like borders, but do not take up any space — they sit on top of the canvas.

Outline (outline-color, outline-style, outline-width)

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

outline-color

8

1.5

Default

none

outline-style

8

1.5

Applies to

All elements

outline-width

8

1.5

  

outline

8

1.5

  

Table Properties

Table properties allow you to affect the style of tables, rows, and cells.

border-collapse

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

collapse

5

1

Default

collapse

separate

5

1

Applies to

Table and inline elements

inherit

8

1

  

border-spacing

This specifies the distance between adjacent cells' borders.

table {border-spacing:2px;}

Value

IE

FF

Inherited

Yes

[length]

8

1

Default

0

inherit

8

1

Applies to

Table and inline elements

caption-side

This indicates which side of a table a caption should be placed on.

caption {caption-side:bottom;}

Value

IE

FF

Inherited

Yes

top

8

1

Default

top

left

8

1

Applies to

<caption> elements in <table> elements

bottom

8

1

  

right

8

1

  

inherit

8

1

  

empty-cells

This specifies whether borders should be displayed if a cell is empty.

td, th {empty-cells:hide;}

Value

IE

FF

Inherited

Yes

show

5

1

Default

show

hide

5

1

Applies to

Table cell elements

inherit

8

1

  

table-layout

Specifies how the browser should calculate the layout of a table; can affect the speed of rendering a large or graphics-intensive table.

Value

IE

FF

Inherited

No

auto

5

1

Default

auto

fixed

5

1

Applies to

Table and inline elements

inherit

8

6

  

Classification Properties

Classification properties affect how the boxes in the box model are rendered.

clear

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

none

4

1

Default

none

both

4

1

Applies to

All elements

left

4

1

  

right

4

1

  

inherit

8

1

  

display

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

none

4

1

Default

inline

inline

5

1

Applies to

All elements

block

5

1

  

list-item

5

1

  

inherit

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.

float

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

none

4

1

Default

none

left

4

1

Applies to

All elements

right

4

1

  

inherit

8

1

  

visibility

Specifies whether an element should be displayed or hidden. Even if hidden, elements take up space on the page, but are transparent.

Value

IE

FF

Inherited

No

visible

4

1

Default

inherit

show

8

1

Applies to

All elements

hidden

4

1

  

hide

8

1

  

collapse

8

1

  

inherit

8

1

  

Internationalization Properties

Internationalization properties affect how text is rendered in different languages.

direction

Specifies the direction of text from left to right or right to left. This should be used in association with the unicode-bidi property.

td.word{direction:rtl; unicode-bidi:bidi-override;}

Value

IE

FF

Inherited

Yes

ltr

5

1

Default

ltr

rtl

5

1

Applies to

All elements

inherit

8

1

  

unicode-bidi

The unicode-bidi property allows you to override Unicode's built-in directionality settings for languages.

td.word{unicode-bidi:bidi-override; direction:rtl; }

Value

IE

FF

Inherited

No

normal

5

2

Default

normal

embed

5

2

Applies to

All elements

bidi-override

5

2

  

inherit

8

2

  

Lengths

Following are the unit measurements for lengths that can be used in CSS.

Absolute Lengths

Unit

IE

FF

cm

3

1

in

3

1

mm

3

1

pc

3

1

pt

3

1

Relative Lengths

Unit

IE

FF

em

4

1

ex

4

1

px

3

1

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.143.207