Difference between revisions of "Style rule (CSS)"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
Line 40: Line 40:
 
* [[Cascading Style Sheets]]
 
* [[Cascading Style Sheets]]
 
* [[CSS property]]
 
* [[CSS property]]
 
+
* [[Media query (CSS)]]
  
  
 
[[Category:Cascading Style Sheets]]
 
[[Category:Cascading Style Sheets]]

Revision as of 20:28, 5 October 2016

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