Difference between revisions of "Style rule (CSS)"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(See also)
 
(One intermediate revision by the same user not shown)
Line 39: Line 39:
 
* [[Box model (CSS)]]
 
* [[Box model (CSS)]]
 
* [[Cascading Style Sheets]]
 
* [[Cascading Style Sheets]]
 +
* [[Class attribute (HTML)]]
 +
* [[Class selector (CSS)]]
 
* [[CSS property]]
 
* [[CSS property]]
 +
* [[HTML element selector (CSS)]]
 +
* [[ID selector (CSS)]]
 
* [[Media query (CSS)]]
 
* [[Media query (CSS)]]
 
+
* [[Style sheet (web design)]]
  
 
[[Category:Cascading Style Sheets]]
 
[[Category:Cascading Style Sheets]]

Latest revision as of 20:33, 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