Background and Foreground Colors
HTML provides background properties that specify the background color and image for the Web pages. To specify a background for a Web page, use the background property. The
background property is a shorthand property that specifies all the background properties in just one declaration.
The bgcolor attribute specifies the background color of a document. The syntax for bgcolor is shown.
Syntax:
where,
color_name - Specifies the background color with a color name (such as "red")
hex_number - Specifies the background color with a hex code (such as "#ff000")
rgb_number - Specifies the background color with an rgb code (such as"rgb(255,0,0)")
Another way to specify a background color for a Web page is by using the style="background-color: color" attribute. This attribute must be added to the <body> tag. An example for applying a background color using the style attribute is as follows:
Example:
The color name 'yellow' can also be replaced by the hex code or the rgb code.
The default text color of the page is specified as the foreground color. The foreground color can be specified by using the style="color: color" attribute. An example for applying a background and foreground color using the style attribute is as follows:
The default text color of the page is specified as the foreground color. The foreground color can be specified by using the style="color: color" attribute. An example for applying a background and foreground color using the style attribute is as follows:
Example:
No comments: