Appendix C. CSS1 PropertiesThis appendix lists all CSS1 properties, plus the CSS1 pseudo-elements and pseudo-classes. The values to the right of a property name show the browser compatibility information for that property. They will look something like this:
The browsers listed are:
The first value in each pair is for the Windows version; the second value is for the Macintosh version. (Sorry, Macintosh folks, but we are in the minority.) For instance, IE4 Y/N means that the property is supported in IE4 for Windows, but not IE4 for Macintosh. The possible support values are:
For more detailed information about browser support, including notes on the support ratings, see Appendix D, "CSS Support Chart".
This pseudo-class applies to hyperlinks, but not named anchors. It sets the styles to be used at the moment a hyperlink is being selected (e.g., clicked). ExampleA:active {color: red; background: yellow;} Valuesn/a Defaultn/a Inheritedyes Applies toanchor elements with an HREF attribute
Applies styles to the first letter of an element. This pseudo-class can be used to generate drop-cap effects, among other things. ExampleP:first-letter {color: purple;} <P>The capital 'T' at the beginning of this paragraph is purple.</P> Valuesn/a Defaultn/a Inheritedyes Applies toblock
Applies styles to the first line of an element. The styles are applied even if the window is resized; the text is simply restyled to encompass only the first line of the element. ExampleP:first-line {color: red;} <P>The first line of this paragraph is red. blah blah blah...</P> Valuesn/a Defaultn/a Inheritedyes Applies toblock
Style declaration is made important, thereby raising its weight in the cascade. Important declarations override all others. In CSS1, important author styles override all reader styles, even important ones. In CSS2, this is reversed, so that important reader styles always win out over the author's styles, important or otherwise. ExampleH1 {color: maroon !important;} P.warning {color: rgb(100%,20%,20%) !important; font-weight: bold;} Valuesn/a Defaultn/a Inheritedyes Applies tostyle rules
This pseudo-class applies to hyperlinks, but not named anchors. It sets the styles to be used for a hyperlink that points to a URI that has not yet been visited (i.e., is not listed in the browser's history). ExampleA:link {color: blue;} Valuesn/a Defaultn/a Inheritedyes Applies toanchor elements with an HREF attribute
This pseudo-class applies to hyperlinks, but not named anchors. It sets the styles to be used for a hyperlink that points to a URI that has already been visited (i.e., is listed in the browser's history). ExampleA:visited {color: navy;} Valuesn/a Defaultn/a Inheritedyes Applies toanchor elements with an HREF attribute
A shorthand way of expressing the various background properties using a single rule. Use of this property is encouraged over the other background properties because it is more widely supported and doesn't take as long to type. ExampleBODY {background: white url(bg41.gif) fixed center repeat-x;} P {background: #555 url(http://www.pix.org/stone.png);} PRE {background: yellow;} Values
Defaultrefer to individual properties Inheritedno Applies toall elements Percentage values allowed on <background-position>.
This property defines whether or not the background image scrolls along with the element. This is generally applied to BODY only, and in fact is largely supported only for that element. It is theoretically possible to create "aligned" backgrounds in multiple elements using this property; see Chapter 6, "Colors and Backgrounds", for more details. ExampleBODY {background-attachment: scroll;} DIV.fixbg {background-attachment: fixed;} Valuesscroll | fixed Defaultscroll Inheritedno Applies toall elements
This sets the background color of an element. The color fills the content area and padding, and extends out to the outer edge of the element's border. The value transparent trips across a nasty bug in Navigator 4.x, which interprets it as black. ExampleH4 {background-color: white;} P {background-color: rgb(50%,50%,50%);} PRE {background-color: #FFFF99;} Values<color> | transparent Defaulttransparent Inheritedno Applies toall elements
Sets an image to be the background pattern. Depending on the value of background-repeat, the background image may tile indefinitely, or only along one axis, or not at all, and the starting position of the tiling is dependent on the value of background-position. ExampleBODY {background-image: url(bg41.gif);} H2 {background-image: url(http://www.pix.org/dots.png);} Values<url> | none Defaultnone Inheritedno Applies toall elements
This sets the starting position of a background image (defined by the value of background-image). background-position is used to set the origin of the background's tiling, or its position if there is no tiling. Percentage values define not only a point within the element, but also the same point in the origin image itself; see Chapter 6, "Colors and Backgrounds" for more details. ExampleBODY {background-position: top center;} Values
Default0% 0% Inheritedno Applies toblock-level and replaced Percentage values refer to the size of the element itself as well as the size of the origin image.
Sets the repeat style for a background image. Note that the axis-related repeats actually repeat in both directions along the specified axis. The repeating of a background image begins with the origin image, whose position is defined by the value of background-position. ExampleBODY {background-repeat: no-repeat;} Valuesrepeat | repeat-x | repeat-y | no-repeat Defaultrepeat Inheritedno Applies toall elements
This is a shorthand property that defines the width, color, and style of the border of an element. Note that while none of the values are required, omitting the <border-style> value will result in no border being applied, since the default of border-style is none. ExampleH1 {border: 2px dashed maroon;} Values<border-width> || <border-style> || <color> Defaultnot defined for shorthand properties Inheritedno Applies toall elements
This shorthand property defines the width, color, and style of the bottom border of an element. The same caveats about border-style apply. ExampleUL {border-bottom: 0.5in inset green;} Values<border-bottom> || <border-style> || <color> Defaultnot defined for shorthand properties Inheritedno Applies toall elements
Sets the width of the bottom border of an element, which will inherit the element's background, and may have a foreground of its own (see border-style). Negative length values are not permitted. ExampleUL {border-bottom-width: 0.5in;} Valuesthin | medium | thick | <length> Defaultmedium Inheritedno Applies toall elements
Sets the color of the foreground of the overall border of an element (see border-style). ExampleH1 {border-color: purple; border-style: solid;} Values<color>{1,4} Defaultthe value of color for the element itself Inheritedno Applies toall elements
This shorthand property defines the width, color, and style of the left border of an element. The usual caveats about border-style apply. ExampleP {border-left: 3em solid gray;} Values<border-left> || <border-style> || <color> Defaultnot defined for shorthand properties Inheritedno Applies toall elements
Sets the width of the left border of an element, which will inherit the element's background, and may have a foreground of its own (see border-style). Negative length values are not permitted. ExampleP {border-left-width: 3em;} Valuesthin | medium | thick | <length> Defaultmedium Inheritedno Applies toall elements
This shorthand property defines the width, color, and style of the right border of an element. The usual caveats about border-style apply. ExampleIMG {border-right: 30px dotted blue;} Values<border-right> || <border-style> || <color> Defaultnot defined for shorthand properties Inheritedno Applies toall elements
Sets the width of the right border of an element, which will inherit the element's background, and may have a foreground of its own (see border-style). Negative length values are not permitted. ExampleIMG {border-right-width: 30px;} Valuesthin | medium | thick | <length> Defaultmedium Inheritedno Applies toall elements
Sets the style of the overall border of an element, using the color set by border-color or the foreground of the element itself if no border-color has been defined. CSS1 does not require recognition of any values besides none and solid. Any unrecognized value from the list of values should be reinterpreted as solid. ExampleH1 {border-style: solid; border-color: purple;} Values
Defaultnone Inheritedno Applies toall elements
This shorthand property defines the width, color, and style of the top border of an element. The usual caveats about border-style apply. ExampleUL {border-top: 0.5in solid black;} Values<border-top> || <border-style> || <color> Defaultnot defined for shorthand properties Inheritedno Applies toall elements
Sets the width of the top border of an element, which will inherit the element's background, and may have a foreground of its own (see border-style). Negative length values are not permitted. ExampleUL {border-top-width: 0.5in;} Valuesthin | medium | thick | <length> Defaultmedium Inheritedno Applies toall elements
Sets the width of the overall border of an element, which will inherit the element's background, and may have a foreground of its own (see border-style). Negative length values are not permitted. ExampleH1 {border-width: 2ex;} Values[ thin | medium | thick | <length> ]{1,4} Defaultnot defined for shorthand properties Inheritedno Applies toall elements
Defines the sides of an element on which no floating images may be placed. The effect of this is to move the element downward until the top of its border-edge is below the bottom edge of the floated element. ExampleH1 {clear: right;} Valuesnone | left | right | both Defaultnone Inheritedno Applies toall elements
Sets the foreground color of a given element. For text, this sets the text color. The value of color is inherited by any borders of an element, unless they have had a color set border-color. ExampleSTRONG {color: rgb(255,128,128);} Values<color> DefaultUA specific Inheritedyes Applies toall elements
Used to classify elements into broad categories. The most popular value is probably none, which suppresses the display of an element altogether. Gratuitous use of display with a document type such as HTML can be dangerous, since HTML already has a display hierarchy defined. However, in the case of XML, which has no such hierarchy, display is indispensable. In CSS2, the range of values for display is dramatically expanded. See Chapter 10, "CSS2: A Look Ahead", for more details. Example.hide {display: none;} Valuesblock | inline | list-item | none Defaultblock Inheritedno Applies toall elements
Sets the float direction for an element. This is generally applied to images in order to allow text to flow around them, but under CSS1 any element may be floated. Note that, for elements such as paragraph, floating the element will cause its width to tend toward zero unless an explicit width is assigned; thus, width assignment is a crucial part of floating any nonreplaced element. ExampleIMG {float: left;} Valuesleft | right | none Defaultnone Inheritedno Applies toall elements
This is a shorthand property for the other font properties. Any of these values may be omitted except for font-size and font-family, which are always required for a valid font declaration. Note the following incorrect examples. ExampleP {font: bold 12pt/14pt Helvetica,sans-serif;} P.wrong {font: bold Helvetica,sans-serif;} /* missing a font-size */ P.wrong {font: 12pt Times,serif bold;} /* font-weight must come before others */ P.wrong {font: 12pt italic Times;} /* font-style must come before font-size */ P.fancy {font: 14pt Author;} /* technically correct, although generic font-families are encouraged for fallback purposes */ Values
Defaultrefer to individual properties Inheritedyes Applies toall elements
This is used to declare a specific font to be used, or a generic font family, or both. Note that the use of a specific font family is dependent on the user having said font installed on the system. Thus the use of generic font families is strongly encouraged, since this will cause the user agent to attempt to substitute a similar font. ExampleP {font-family: Helvetica,sans-serif;} Values
DefaultUA specific Inheritedyes Applies toall elements
This sets the size of the font. This can be defined as an absolute size, a relative size, a length value, or a percentage value. Negative length and percentage values are not permitted. The dangers of font-size assignment are many and varied. Some of these dangers are covered in Chapter 4, "Text Properties". ExampleH2 {font-size: 200%;} H3 {font-size: 36pt;} Values
Defaultmedium Inheritedyes Applies toall elements Percentage values are relative to the parent element's font size.
This set the font to use either italic, oblique, or normal text. Italic text is generally a defined font face within the font itself, whereas oblique text is less often so. In the latter case, the user agent can compute a slanted font face. ExampleEM {font-style: oblique;} Valuesnormal | italic | oblique Defaultnormal Inheritedyes Applies toall elements
This property currently has two values: small-caps and normal. The small-caps variant can either be applied as a face of the selected font or computed by the user agent. ExampleH3 {font-variant: small-caps;} Valuesnormal | small-caps Defaultnormal Inheritedyes Applies toall elements
This is used to set the weight of a font, making it heavier or lighter. The numeric value 400 is equivalent to the value normal, and 700 is equal to bold. Each numeric value is at least as heavy as the next-lower value, and at least as light as the next-higher number. ExampleB {font-weight: 700;} Values
Defaultnormal Inheritedyes Applies toall elements
This is used to set the height of an element. Height is most often applied to images, but can be used on any block-level or replaced element, although support for such behavior is not widespread as of this writing. Negative length values are not permitted. ExampleIMG.icon {height: 50px;} Values<length> | auto Defaultauto Inheritedno Applies toblock-level and replaced
Used to set the amount of whitespace between letters. A letter is defined as any displayed character, including numbers, symbols, and other font glyphs. Length values are used to define a modifier to the usual spacing, not the entire space itself; thus, normal is synonymous with 0 (zero). Negative values are permitted, and cause the letters to bunch closer together. ExampleP {letter-spacing: 0.5em;} Valuesnormal | <length> Defaultnormal Inheritedyes Applies toall elements
This influences the layout of line boxes. The difference between the value of line-height and the value of font-size is called leading, and half of the leading (otherwise known as half-leading) is applied above and below the content of an element or line of text. Negative values are not permitted. Using a number defines a scaling factor that is multiplied by the font-size, and the number itself is inherited, not the computed value. This allows for much more intelligent page layout, and is strongly preferred over other methods of setting line-height. The drawback to using a number value is that IE3 will interpret it as a number of pixels. See Chapter 8, "Visual Formatting" for a detailed discussion of line-height and line boxes. ExampleP {line-height: 18pt;} H2 {line-height: 200%;} Valuesnormal | <number> | <length> | <percentage> Defaultnormal Inheritedyes Applies toall elements Percentage values relative to the font size of the element itself
A shorthand property condensing all other list-style properties. It applies to all elements with a display value of list-item ; in ordinary HTML, this is any <LI> element. ExampleUL {list-style: square url(bullet3.gif) outer;} /* values are inherited by LI elements */ Values
Defaultnot defined for shorthand properties Inheritedyes Applies toelements with display of list-item
Used to declare an image which is to be used as the "bullet" in an unordered or ordered list. This style applies to elements with a display value of list-item (e.g., <LI> elements). The position of the image with respect to the content of the list item is defined using list-style-position. ExampleUL {list-style-image: url(bullet3.gif);} Values<url> | none Defaultnone Inheritedyes Applies toelements with display of list-item
This property is used to declare the position of the bullet or number in an unordered or ordered list with respect to the content of the list item. Applies to elements with a display value of list-item. If the bullet is set to be outside, then it is placed in the margin of the list-item element. The exact behavior in this circumstance is not defined in CSS. ExampleLI {list-style-position: outer;} Valuesinside | outside Defaultoutside Inheritedyes Applies toelements with display of list-item
This is used to declare the type of bullet numbering system to be used in either an unordered or ordered list, depending on the value specified. This property applies to elements with a display value of list-item. ExampleUL {list-style-type: square;} OL {list-style-type: lower-roman;} Values
Defaultdisc Inheritedyes Applies toelements with display of list-item
This sets the size of the overall margin of an element. Vertically adjacent margins of block-level elements are collapsed to be as large as the largest margin, whereas inline elements effectively do not take margins (they are allowed, but have no effect on page layout). Only the left and right margins of inline elements have any effect, and are not collapsed. Margins set on floated elements are not collapsed with other margins under any circumstance. Negative values are permitted, but caution is recommended. ExampleH1 {margin: 2ex;} Values[ <length> | <percentage> | auto ]{1,4} Defaultnot defined for shorthand properties Inheritedno Applies toall elements Percentage values refer to width of the closest block-level ancestor.
This sets the size of the bottom margin of an element. Negative values are permitted, but caution is recommended. ExampleUL {margin-bottom: 0.5in;} Values<length> | <percentage> | auto Default0 Inheritedno Applies toall elements Percentage values refer to the width of the closest block-level ancestor.
This sets the size of the left margin of an element. Negative values are permitted, but caution is recommended. ExampleP {margin-left: 3em;} Values<length> | <percentage> | auto Default0 Inheritedno Applies toall elements Percentage values refer to width of the closest block-level ancestor.
This sets the size of the right margin of an element. Negative values are permitted, but caution is recommended. ExampleIMG {margin-right: 30px;} Values<length> | <percentage> | auto Default0 Inheritedno Applies toall elements Percentage values refer to width of the closest block-level ancestor.
This sets the size of the top margin of an element. Negative values are permitted, but caution is recommended. ExampleUL {margin-top: 0.5in;} Values<length> | <percentage> | auto Default0 Inheritedno Applies toall elements Percentage values refer to the width of the closest block-level ancestor.
This sets the size of the overall padding of an element. The padding will "inherit" the element's background; in other words, the background of an element fills its content area and padding. Padding set on inline elements does not affect line-height calculations, but will be applied to the right and left ends of the element. If an inline element has both padding and a background, the background may be extended above and below the edges of the line-box in which the inline element appears, but user agents are not required to support this behavior. There is also no defined behavior to say whether the foreground content of a previous line appears above the background of a succeeding line, or is overwritten by that background. Negative values are not permitted. ExampleH1 {padding: 2ex;} Values[ <length> | <percentage> ]{1,4} Defaultnot defined for shorthand properties Inheritedno Applies toall elements Percentage values refer to the width of closest block-level ancestor.
This property sets the size of the bottom padding of an element, and this padding will "inherit" the element's background. Negative values are not permitted. ExampleUL {padding-bottom: 0.5in;} Values<length> | <percentage> Default0 Inheritedno Applies toall elements Percentage values refer to the width of closest block-level ancestor.
This property sets the size of the left padding of an element, and this padding will "inherit" the element's background. Negative values are not permitted. ExampleP {padding-left: 3em;} Values<length> | <percentage> Default0 Inheritedno Applies toall elements Percentage values refer to the width of closest block-level ancestor.
This property sets the size of the right padding of an element, and this padding will "inherit" the element's background. Negative values are not permitted. ExampleIMG {padding-right: 30px;} Values<length> | <percentage> Default0 Inheritedno Applies toall elements Percentage values refer to the width of closest block-level ancestor.
This property sets the size of the top padding of an element, and this padding will "inherit" the element's background. Negative values are not permitted. ExampleUL {padding-top: 0.5in;} Values<length> | <percentage> Default0 Inheritedno Applies toall elements Percentage values refer to the width of the closest block-level ancestor.
This sets the horizontal alignment of the text in an element, or more precisely, defines to which side of the element the line-boxes are aligned. The value justify is supported by programmatically adjusting the letter- and word-spacing of the line's content, and results may vary by user agent. ExampleP {text-align: justify;} H4 {text-align: center;} Valuesleft | right | center | justify DefaultUA specific Inheritedyes Applies toblock
This property sets certain effects on the text, such as underline and blink. These decorations will "span" child elements that do not have text decoration defined; see Chapter 4, "Text Properties" for more details. Combinations of the values are legal. User agents are not required to support the value blink, and in fact only Netscape Navigator 4.x does so. ExampleU {text-decoration: underline;} .old {text-decoration: line-through;} U.old {text-decoration: line-through underline;} Valuesnone | [ underline || overline || line-through || blink ] Defaultnone Inheritedno Applies toall elements
Used to set the indentation of the first line of an element. This is most often used to create a tab effect for Negative values are permitted, and cause "hanging indents." ExampleP {text-indent: 5em;} H2 {text-indent: -25px;} Values<length> | <percentage> Default0 Inheritedyes Applies toblock Percentage values refer to parent element's width.
This property changes the case of the letters in the element, regardless of the case of the original text. The selection of letters to be capitalized by the value capitalize is not a precisely defined behavior, depending as it does on "words," which are difficult to define in a programmatic way. ExampleH1 {text-transform: uppercase;} .title {text-transform: capitalize;} Valuescapitalize | uppercase | lowercase | none Defaultnone Inheritedyes Applies toall elements
Used to set the vertical alignment of an element's baseline with respect to its line-height. Negative percentage values are permitted, and will cause the element to be lowered, not raised. ExampleSUP {vertical-align: super;} .fnote {vertical-align: 50%;} Values
Defaultbaseline Inheritedno Applies toinline Percentage values refer to the line height of the element itself.
This property defines how whitespace within the element is treated. normal acts like traditional web browsers, in that it reduces any sequence of whitespace to a single space. pre causes whitespace to be treated as it is in the HTML element PRE, with whitespace and returns preserved. nowrap prevents an element from line breaking. ExampleTD {white-space: nowrap;} TT {white-space: pre;} Valuesnormal | pre | nowrap Defaultnormal Inheritedyes Applies toblock
Used to set the width of an element. This is most often applied to images, but can be used on any block-level or replaced element. Negative values are not permitted. ExampleTABLE {width: 80%;} Values<length> | <percentage> | auto Defaultauto Inheritedno Applies toblock-level and replaced Percentage values refer to the parent element's width.
Used to set the amount of whitespace between words. A "word" is defined as a string of characters surrounded by whitespace. Length values are used to define a modifier to the usual spacing, not the entire space itself; thus, normal is synonymous with 0 (zero). Negative values are permitted, and cause the words to bunch closer together. ExampleP {word-spacing: 0.5em;} Valuesnormal | <length> Defaultnormal Inheritedyes Applies toCopyright © 2002 O'Reilly & Associates. All rights reserved. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|