advertisement
Background and Foreground Colors in HTML
HTML provides background properties that specify the background color and image for Web pages. To select a background for a Web page, use the background property. The background property is a shorthand property that stipulates all the background properties in just one declaration.
The bgcolor attribute specifies the background color of a document.
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 " #ff0000")
- 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 style="background-color: color". This attribute must be added to the <body> tag. An example of 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 of applying a background and foreground color using the style attribute is as follows:
Example:
Background Image File
A Website developer can also insert an image as the background on a Web page. These background images are not recommended as sometimes the colors in the image may hide the text content. Hence, it is best to choose images with lighter shades. Also, as the image is tiled, it is best to choose an image that blends well and looks like a single image even after it is tiled.
advertisement
Conversation
Your input fuels progress! Share your tips or experiences on prioritizing mental wellness at work. Let's inspire change together!
Join the discussion and share your insights now!
Comments 0