|
In web
development, Cascading Style Sheets (CSS) is a
stylesheet language used to describe the presentation of
a document written in a markup language. Its most common
application is to style web pages written in HTML and
XHTML, but the language can be applied to any kind of
XML document, including SVG and XUL.
CSS is used by both the authors and readers of web pages
to define colors, fonts, layout, and other aspects of
document presentation. It is designed primarily to
enable the separation of document content (written in
HTML or a similar markup language) from document
presentation (written in CSS). This separation can
improve content accessibility, provide more flexibility
and control in the specification of presentational
characteristics, and reduce complexity and repetition in
the structural content. CSS can also allow the same
markup page to be presented in different styles for
different rendering methods, such as on-screen, in
print, by voice (when read out by a speech-based browser
or screen reader) and on Braille-based, tactile devices.
CSS specifies a priority scheme to determine which style
rules apply if more than one rule matches against a
particular element. In this so-called cascade,
priorities or weights are calculated and assigned to
rules, so that the results are predictable.
┐See Also: .Professional
Websites starting at $15/month
Prior to
CSS, nearly all of the presentational attributes of HTML
documents were contained within the HTML markup; all
font colors, background styles, element alignments,
borders and sizes had to be explicitly described, often
repeatedly, within the HTML. CSS allows authors to move
much of that information to a separate stylesheet
resulting in considerably simpler HTML markup.
Headings (h1 elements), sub-headings (h2),
sub-sub-headings (h3) etc. are defined structurally
using HTML. In print and on the screen, choice of font,
size, color and emphasis for these elements is
presentational.
Prior to CSS, document authors who wanted to assign such
typographic characteristics to, say, all h2 headings had
to use the HTML font and other presentational elements
for each occurrence of that heading type. The additional
presentational markup in the HTML made documents more
complex, and generally more difficult to maintain. To
render all h2 tags in this manner, the markup had to be
repeated for each heading. In CSS, presentation is
separated from structure. In print, CSS can define
color, font, text alignment, size, borders, spacing,
layout and many other typographic characteristics. It
can do so independently for on-screen and printed views.
CSS also defines non-visual styles such as the speed and
emphasis with which text is read out by aural text
readers. The W3C now considers the advantages of CSS for
defining all aspects of the presentation of HTML pages
to be superior to other methods. It has therefore
deprecated the use of all the original presentational
HTML markup. |