Contents Index Topic Contents | ||
Previous Topic: active Next Topic: background-attachment |
background
Description
Sets all background attributes (image, attachment, color, repeat, position) for an element at once.
Syntax
{ background: background-color || background-image || background-repeat || background-attachment || background-position}
Remarks
While separate attributes can be used to specify the individual background properties, it is often more convenient to set them in one place using this composite property.
Individual background properties not set by the composite background property will be set to their default values. For example, the default 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.
For more information on supported colors, see Color Table.
This property does not inherit, but the parent element's background will display through by default due to the default transparent value.
Examples
The first example below sets the background-color for DIV elements to red and sets all other background properties to their default 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
Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.