CSS Background-Color Property Values

Updated on 09 Sep 2009, Published on 04 Jun 2009

CSS background-color property accepts value as color name, RGB color or RGB based hexadecimal code that sets the background color to the HTML elements. This property highlights the background of HTML element based on the color code value.

CSS Background Examples:

You can see the live samples and examples of CSS Background Properties from the following links:

Syntax

background-color: [#RRGGBB] | [Named Color] | [rgb(R, B, G)] | Transparent | inherit;

Examples

Using Hex Color Code:

background-color: #c0c0c0;

Using Named Color:
background-color: Red;

Using RGB Color:
background-color: rgb(255, 0, 0);

Hexadecimal color code value contains combination of values of RGB. First 2 letters define the hex code for R i.e. Red, next 2 letters define the hex code for G i.e. Green and last 2 letters for B i.e. Blue. "#" hash symbol is compulsory as a prefix to the hex color code.

Named color values consist of basic color names such as red, blue, green, yellow, cyan, aqua etc. In addition you can also use System colors such as ActiveBorder, GrayText, Highlight, HighlightText etc.

RGB color code requires values of R, G and B separately for example RGB(192, 192, 192). First value for Red(R), second parameter for Green(G), and last parameter for Blue(B).

By default value of background-color property is "Transparent".

Last value "inherit" specifies that background-color property value should be inherited from the parent element, but this value is not supported by all the browsers.

Output:

Get the output of above discussed examples from the following link:

CSS Background-Color

Continue next to learn the CSS Background-image property with examples.

Product Spotlight

Share it
Rate this article:
Email it:
email

0 Responses to "CSS Background-Color Property Values"
Leave a Reply

Name   (Required)


Mail   (will not be published) (Required)


Website   (http://www.example.com)




OR Subscribe via Email: