CSS

Background Property

Uses for the Background Property
Body Headings Paragraphs Tables
background-color:#FFFFF0; background-color:aliceblue background-color:lime background-color:maroon
body declaration block heading declaration block paragraph declaration block table declaration block

Examples

  1. body {background-color:#FFFFF0; }
  2. h2 {background-color:red; }
  3. p {background-color: lime; }
  4. table {background-color:blue; }

More Reading


Key Definitions for Style Rules

Selector
- specifies which HTML element is the target of the rule. It may be a list of elements separated by commas.
Declaration Block
- declarations are encased in a set of braces and separated by semi-colons.
Property
- property: value indicates the value assigned to the property.

Specifying an External Style Sheet

link tag
- placed in the head section after the closing title tag.
type attribue
- assigned the value "text/css" to indicate the CSS language is being used.
rel attribute
- assigned the "stylesheet" relationship value.
href attribute
- assigned the filename of the CSS stylesheet file.

There are other situations where the background property may be used.

Now for a few paragraph IDs to finish off.

No id on this paragraph.

This paragraph had id3.

No id on this paragraph.

And now a pair of short paragraphs to illustrate the combination of classes with the span element.
By defining a class for an element, span in this case, we can reuse the class unlike the situation with IDs.

This page was intended to deal with the background-color property and, while it does a lot of that, several other aspects of CSS have been included.

Paragraph with border.

Paragraph with border and background as classes are combined.