|
Find 2000 Affordable Web Site Templates, software, and scripts at Webmasters Profit Pak
Using Web Templates for Web Design: Tips and Best Practices
Style Sheets, Rules, Selectors, Declarations
A style sheet is a set of one or more "rules" that apply to an HTML
document. A "rule" is a statement about one stylistic aspect of one
or more HTML elements (tags). Rules can be separated into two distinct components:
selectors and declarations.
Selectors
HTML tags or "elements" are also known as selectors in CSS. The selector
becomes the link between the style and its application in the document. All
HTML tags are potential selectors and when a style "rule" is created
for an HTML tag, it will effect all occurrences of that tag in the document..
Two varieties of selectors may be used:
- Type (most commonly used)
- Attribute (Class or ID)
Declarations
A CSS declaration consists of two parts:
- Property (e.g., 'color')
- Value (e.g., 'blue').
CSS1 supports more than 50 different properties which can be applied to selectors
(HTML tags) to determine their presentation in an HTML document.
Properties include:
- background (color or graphic)
- font-size
- font-weight
- line-height (leading or interlinear spacing)
- font-family
- letter-spacing and word-spacing
A rule generically looks like this:
selector { property: value; }
=================
declaration
For example, to cause the first line of a paragraph to indent:
p { text-indent: 3em; }
P is the selector, and the rule has just one declaration -
that the text-indent property of the paragraph will be 3em. If
this style was in your document, it would indent all paragraphs 3ems.
|