HTML and CSS Reference
In-Depth Information
8.1. The Elements of Styles
At the simplest level, a style is nothing more than a rule the browser fol-
lows to render a particular HTML or XHTML tag's contents. [*] Each tag
has a number of style properties associated with it, whose values define
how that tag is rendered by the browser. A rule defines a specific value
for one or more properties of a tag. For example, most tags can have a
color property, the value of which defines the color in which the mod-
ern GUI browser should display the contents of the tag. Other properties
include fonts, line spacing, margins, borders, sound volume, and voice,
which we describe in detail later in this chapter.
[*] We explicitly avoided the term display here because it connotes visual presentation, whereas the
CSS2 standard works hard to suggest many different ways of presenting the tagged contents of a doc-
ument.
There are three ways to attach a style to a tag: inline, on the document
level, or through the use of an external stylesheet. You may use one
or more stylesheets for your documents. The browser either merges the
style definitions from each style or redefines the style characteristic for
a tag's contents. Styles from these various sources are applied to your
document, combining and defining style properties that cascade from ex-
ternal stylesheets through local document styles, and ending with inline
styles. This cascade of properties and style rules gives rise to the stand-
ard's name: Cascading Style Sheets.
We cover the syntactic basics of the three stylesheet techniques here.
We delve more deeply into the appropriate use of inline, document-level,
and external stylesheets at the end of this chapter.
8.1.1. Inline Styles: The style Attribute
The inline style is the simplest way to attach a style to a tagjust include
a style attribute with the tag along with a list of properties and their val-
ues. The browser uses those style properties and values to render the
contents of that tag.
 
 
Search WWH ::




Custom Search