The background-color
property specifies the background color of an element.
The background color of a page is set like this:
You can add comments wherever you want in the code:
With CSS, a color is most often specified by:
Look at CSS Color Values for a complete list of possible color values.
You can set the background color for any HTML elements:
Here, the <h1>, <p>, and <div> elements will have different background colors:
The opacity
property specifies the opacity/transparency of an element. It can take a value from 0.0 - 1.0. The lower value, the more transparent:
If you do not want to apply opacity to child elements, like in our example above, use RGBA color values. The following example sets the opacity for the background color and not the text:
An RGBA color value is specified with: rgba(red, green, blue, alpha). The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully opaque).