Difference between revisions of "Style rule (CSS)"
From Wiki @ Karl Jones dot com
Karl Jones (Talk | contribs) (→See also) |
Karl Jones (Talk | contribs) |
||
Line 1: | Line 1: | ||
− | In [[Cascading Style Sheets]], a '''style rule''' is a definition which affects the presentation of [[HTML]]. | + | 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: | ||
+ | |||
+ | <pre> | ||
+ | selector { | ||
+ | property:value; | ||
+ | property:value | ||
+ | } | ||
+ | </pre> | ||
+ | |||
+ | 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 == | == Example == |
Revision as of 19:21, 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>