Style rule (CSS)

From Wiki @ Karl Jones dot com
(Redirected from Style rules)
Jump to: navigation, search

In Cascading Style Sheets, a style rule is a definition which affects the presentation of HTML.

Style rule structure

The basic structure of a style rule:

selector {
  property:value;
  property:value
}

Elements of the style rule:

  • The selector identifies which HTML element(s) will be affected.
  • The property identifies the type of formatting which will be applied.
  • The value sets a value for the property.


Example

Say the HTML looks like this:

<body>...</body>

The style rule below sets the background color for the body of the web page:

<style>
 body { background-color: #cccccc; }
</style>

See also