CSS Attributes Reference

CSS Attributes Reference



active

Description

Sets the style of A elements when the current state of a link is "active". Active means that the user is currently navigating the link. Setting the active pseudo-class is often used in conjunction with setting specific styles for the other states of a link: link, visited, hover. Using pseudo-classes on elements other than the A element has no effect.

Example

Note that the syntax in the following example uses a colon (:) to specify a pseudo-class.

A:active {text-decoration:overline;color:purple}

Applies To

A

See Also

hover, link, visited,


background

Description

Sets all background properties at once. This property is a shorthand ("composite") property. Separate properties can be used to specify each of the individual properties, but in many cases it is more convenient to set them in one place using this composite property. Possible values here include all of the possible values for each of the individual properties.

All individual background properties not set by the composite background property will be set to their initial values. For example, the initial value for "background-image" is none. Setting "background: white" is identical to saying "background: white none repeat scroll 0% 0%". So, in addition to setting the background color to white, it will clear any background-image, background-repeat, background-attachment, or background-position that has been previously set.

Syntax

{ background: background-color || background-image || background-repeat || background-attachment || background-position}

Remarks

This property does not inherit, but the parent element's background will shine through by default due to the initial transparent value.

Examples

The first example below sets the background-color for DIV elements to red and sets all other background properties to their initial values. The second example sets the background for the BODY element to show an image. This image will stay fixed as if it were a watermark on a page. Assuming the image is transparent, the color blue will bleed through.

DIV {background: red}

BODY {background: blue url(sample.gif) fixed}

Applies To

A, ADDRESS, B, BIG, BLOCKQUOTE, BODY, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, DD, DFN, DIR, DIV, DL, DT, EM, FIELDSET, FORM, H1, H2, H3, H4, H5, H6, HTML, I, IMG, INPUT, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, TEXTAREA, KBD, LABEL, LEGEND, LI, LISTING, MARQUEE, MENU, OL, P, PLAINTEXT, PRE, S, SAMP, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP

Scripting Property

background


background-attachment

Description

If a background image is specified, the value of background-attachment determines if it is fixed with regard to the canvas or if it scrolls with the content.

Syntax

{ background-attachment: scroll | fixed}

Remarks

This attribute works only for the BODY and HTML elements.

This attribute is not inherited.

Applies To

A, ADDRESS, B, BIG, BLOCKQUOTE, BODY, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, DD, DFN, DIR, DIV, DL, DT, EM, FIELDSET, FORM, H1, H2, H3, H4, H5, H6, HTML, I, IMG, INPUT, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, TEXTAREA, KBD, LABEL, LEGEND, LI, LISTING, MARQUEE, MENU, OL, P, PLAINTEXT, PRE, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP

Scripting Property

backgroundAttachment


background-color

Description

Sets the background color of an element.

Syntax

{ background-color: color | transparent}

Remarks

This attribute is not inherited.

Applies To

A, ADDRESS, B, BIG, BLOCKQUOTE, BODY, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, DD, DFN, DIR, DIV, DL, DT, EM, FIELDSET, FORM, H1, H2, H3, H4, H5, H6, HTML, I, IMG, INPUT, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, TEXTAREA, KBD, LABEL, LEGEND, LI, LISTING, MARQUEE, MENU, OL, P, PLAINTEXT, PRE, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP

Scripting Property

backgroundColor


background-image

Description

Sets the background image of an element. When setting a background image, one should also set a background color that will be used when the image is unavailable. When the image is available, it is overlaid on top of the background color.

Syntax

{ background-image: url | none}

Remarks

This attribute is not inherited.

Example

BODY { background-image: url(marble.gif) }
P { background-image: none }

Applies To

A, ADDRESS, B, BIG, BLOCKQUOTE, BODY, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, DD, DFN, DIR, DIV, DL, DT, EM, FIELDSET, FORM, H1, H2, H3, H4, H5, H6, HTML, I, IMG, INPUT, KBD, LABEL, LEGEND, LI, LISTING, MARQUEE, MENU, OL, P, PLAINTEXT, PRE, S, SAMP, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP, INPUT type=button, INPUT type=file, INPUT type=reset, INPUT type=submit, INPUT type=text, INPUT type=image, INPUT type=checkbox, INPUT type=radio, INPUT type=password

Scripting Property

backgroundImage


background-position

Description

If a background image has been specified, the value of background-position specifies its initial position.

Syntax

{ background-position: [percentage | length]{1,2} | [top | center | bottom] || [left | center | right]}

Remarks

This attribute is not inherited.

Examples

Sets the background image at these x,y coordinates of the object.

{background-position: 20px 40px}

Positions the background image at the top vertical position and the center horizontal position.

{background-position: top center}

Applies To

A, ADDRESS, B, BIG, BLOCKQUOTE, BODY, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, DD, DFN, DIR, DIV, DL, DT, EM, FIELDSET, FORM, H1, H2, H3, H4, H5, H6, HTML, I, IMG, INPUT, KBD, LABEL, LEGEND, LI, LISTING, MARQUEE, MENU, OL, P, PLAINTEXT, PRE, S, SAMP, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP, INPUT type=button, INPUT type=file, INPUT type=reset, INPUT type=submit, INPUT type=text, INPUT type=image, INPUT type=checkbox, INPUT type=radio, INPUT type=password

Scripting Property

backgroundPosition, backgroundPositionX, backgroundPositionY


background-repeat

Description

Determines how/if the image is repeated, if a background image is specified.

A value of repeat means that the image is repeated both horizontally and vertically. The repeat-x (repeat-y) value makes the image repeat horizontally (vertically), to create a single band of images from one side to the other. With a value of no-repeat, the image is not repeated.

Syntax

{ background-repeat: repeat | repeat-x | repeat-y | no-repeat}

Remarks

This attribute is not inherited.

Example

In the following example, the image will only be repeated vertically.

BODY {background: red url(pendant.gif);
      background-repeat: repeat-y;}

Applies To

A, ADDRESS, B, BIG, BLOCKQUOTE, BODY, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, DD, DFN, DIR, DIV, DL, DT, EM, FIELDSET, FORM, H1, H2, H3, H4, H5, H6, HTML, I, IMG, INPUT, KBD, LABEL, LEGEND, LI, LISTING, MARQUEE, MENU, OL, P, PLAINTEXT, PRE, S, SAMP, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP, INPUT type=button, INPUT type=file, INPUT type=reset, INPUT type=submit, INPUT type=text, INPUT type=image, INPUT type=checkbox, INPUT type=radio, INPUT type=password

Scripting Property

backgroundRepeat


border

Description

Specifies the border to display around the element. The border property is a shorthand (composite) property for setting border width, color, and style for all four sides of an object. If a border-color is not specified, the text color is used. Supported on block and replaced elements only.

All individual border properties not set by the composite border property will be set to their initial values. For example, the initial value for border-width is medium. Setting border: thin is identical to saying border: thin none; the initial value for color picks up the text color if one isn't initially set. So, in addition to setting the border width to thin, it will clear any border-style or border-color that has been previously set.

Syntax

{ border: border-width || border-style || color}

Remarks

This attribute is not inherited.

Example

Creates a border for all four sides of the object, where all four sides show a 20 pixel blue border with an inset style. Use the individual properties to control the border for individual sides of the object.

{border: 20px inset blue}

Applies To

BLOCKQUOTE, BODY, CENTER, DD, DIR, DIV, DL, DT, FIELDSET, FORM, H1, H2, H3, H4, H5, H6, HR, LI, LISTING, MARQUEE, MENU, OL, P, PLAINTEXT, PRE, TABLE, TD, TH, TR, UL, XMP, CAPTION, TEXTAREA, IFRAME, SPAN, IMG, EMBED, OBJECT, INPUT

Scripting Property

border

See Also

border-width, border-style, border-color border-right, border-left, border-top, border-bottom


border-bottom

Description

Specifies the bottom border. Values that are not present are set to their initial values. Supported on block and replaced elements only.

Syntax

{ border-bottom: border-bottom-width || border-style || color}

Remarks

This attribute is not inherited.

Example

In this example, the border will be a solid green line.

{border-bottom: 20px outset green}

Applies To

BLOCKQUOTE, BODY, CENTER, DD, DIR, DIV, DL, DT, FIELDSET, FORM, H1, H2, H3, H4, H5, H6, HR, LI, LISTING, MARQUEE, MENU, OL, P, PLAINTEXT, PRE, TABLE, TD, TH, TR, UL, XMP, CAPTION, TEXTAREA, IFRAME, SPAN, IMG, EMBED, OBJECT, INPUT

Scripting Property

borderBottom

See Also

border-bottom-width, border-bottom-style, border-bottom-color, border, border-top


border-bottom-color

Description

Sets the color of an element's bottom border. Supported on block and replaced elements only. See the Color Table for a list of supported color values.

Syntax

{ border-bottom-color: border-color}

Remarks

This attribute is not inherited.

Applies To

BLOCKQUOTE, BODY, CENTER, DD, DIR, DIV, DL, DT, FIELDSET, FORM, H1, H2, H3, H4, H5, H6, HR, LI, LISTING, MARQUEE, MENU, OL, P, PLAINTEXT, PRE, TABLE, TD, TH, TR, UL, XMP, CAPTION, TEXTAREA, IFRAME, SPAN, IMG, EMBED, OBJECT, INPUT

Scripting Property

borderBottomColor

See Also

border-top-color, border-left-color, border-right-color, border-color

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.