Style sheet (web development)

Style sheet (web development)

Web style sheets are a form of separation of presentation and content for web design in which the markup (i.e., HTML or XHTML) of a webpage contains the page's semantic content and structure, but does not define its visual layout (style). Instead, the style is defined in an external stylesheet file using a language such as CSS or XSL. This design approach is identified as a "separation" because it largely supersedes the antecedent methodology in which a page's markup defined both style and structure.

The philosophy underlying this methodology is a specific case of separation of concerns.

Benefits

Separation of style and content has many benefits, but has only become practical in recent years due to improvements in popular web browsers' CSS implementations.

Speed

Overall, users experience of a site utilising style sheets will generally be quicker than sites that don’t use the technology. ‘Overall’ as the first page will probably load more slowly – because the style sheet AND the content will need to be transferred. Subsequent pages will load faster because no style information will need to be downloaded – the CSS file will already be in the browser's cache.

Maintainability

Holding all the presentation styles in one file significantly reduces maintenance time, and reduces opportunity for human errors by reducing the maintenance tasks.

To illustrate - imagine if you had just finished writing a client's site using embedded content and the client then tells you that the font color should be #3667CA, not the web safe color you have always used for their site. A site using embedded styles would require a large, cumbersome, time consuming and error prone edit of every page.

If you had created the site utilizing CSS technology, and had done it properly, then the only thing you would need to change would be six characters in the CSS file – to be pedantic, you’d only need to change the second, fourth and sixth character of the color code.

Other advantages include clearer (X)HTML pages for easier editing, and an easily achieved consistency of presentation.

Accessibility

Sites that use CSS with either XHTML or HTML are easier to tweak so that they appear extremely similar in different browsers (Internet Explorer, Mozilla Firefox, Opera, Safari, etc.).

Sites using CSS "degrade gracefully" in browsers unable to display graphical content, such as Lynx, or those so very old that they cannot use CSS. Browsers ignore CSS that they do not understand, such as CSS 3 statements. This enables a wide variety of user agents to be able to access the content of a site even if they cannot render the stylesheet or are not designed with graphical capability in mind. For example, a browser using a refreshable braille display for output could disregard layout information entirely, and the user would still have access to all page content.

Customization

If a page's layout information is all stored externally, a user can decide to disable the layout information entirely, leaving the site's bare content still in a readable form. Site authors may also offer multiple stylesheets, which can be used to completely change the appearance of the site without altering any of its content.

Most modern web browsers also allow the user to define their own stylesheet, which can include rules that override the author's layout rules. This allows users, for example, to bold every hyperlink on every page they visit.

Consistency

Because the semantic file contains only the meanings an author intends to convey, the styling of the various elements of the document's content is very consistent. For example, headings, emphasized text, lists and mathematical expressions all receive consistently applied style properties from the external stylesheet. Authors need not concern themselves with the style properties at the time of composition. These presentational details can be deferred until the moment of presentation.

Portability

The deferment of presentational details until the time of presentation means that a document can be easily re-purposed for an entirely different presentation medium with merely the application of a new stylesheet already prepared for the new medium and consistent with elemental or structural vocabulary of the semantic document. A carefully authored document for a web page can easily be printed to a hard-bound volume complete with headers and footers, page numbers and a generated table of contents simply by applying a new stylesheet.

Practical disadvantages today

Currently specifications (for example, XHTML, XSL, CSS) and software tools implementing these specification are only reaching the early stages of maturity. So there are some practical issues facing authors who seek to embrace this method of separating content and style.

Lack of semantic vocabulary

HTML offers a rich, but limited vocabulary of semantic elements (for example paragraph, quote, emphasis). The migration of HTML to the extensible XHTML may eventually speed the proliferation of richer semantic vocabularies to apply generalized styles to. So, for example, extensions such as Ruby (annotation markup), MathML, XForms, XFrames and so forth will bring new elements for use in content documents: elements that will likely have readily available stylesheets for presentation. However, today these missing components mean content authors must create their own ad hoc elements to express themselves.

Complex layouts

One of the practical problems is the lack of proper support for style languages in major browsers. Typical web page layouts call for some tabular presentation of the major parts of the page such as menu navigation columns and header bars, navigation tabs, and so on. However, deficient support for CSS and XSL in major browsers forces authors to code these tables within their content rather than applying a tabular style to the content from the accompanying stylesheet.

Narrow adoption without the parsing and generation tools

While the style specifications are quite mature and still maturing, the software tools have been slow to adapt. Most of the major web development tools still embrace a mixed presentation-content model. So authors and designers looking for GUI based tools for their work find it difficult to follow the semantic web method. In addition to GUI tools, shared repositories for generalized stylesheets would probably aid adoption of these methods.

See also

* Separation of concerns
* Style sheet (desktop publishing)

External Resources

* [http://www.sitepoint.com/article/simply-javascript Simply JavaScript: The Three Layers of the Web]
* [http://www.csszengarden.com CSS Zen Garden] : A site which challenges designers to create new page layouts without touching the XHTML source. Includes dozens of layouts. CSS source can be viewed for every layout.
* [http://www.cameraontheroad.com/?p=189 Revealed - Our HTML and CSS Codes - cameraontheroad.com] : Gives practical examples of CSS advantages from a site which has moved from embedded presentation styles to style sheets. Includes links to CSS resources.
* [http://www.brugbart.com Brugbart] : A site holding Tutorials and References to CSS based, and standard compliant layouts.


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • Style sheet — * Style sheet (desktop publishing) a feature of desktop publishing programs. * Style sheet (web development) W3C standards for web page style sheets such as CSS or XSL. * Style sheet language computer languages that describe the presentation of… …   Wikipedia

  • Style sheet language — A style sheet language is a computer language used to describe the presentation of structured documents. A structured document is a document whose sections are clearly defined and categorized (also called well formed ). A program presenting the… …   Wikipedia

  • Cascading Style Sheets — CSS redirects here. For other uses, see CSS (disambiguation). For the use of CSS on Wikipedia, see Help:Cascading style sheets. Cascading Style Sheets Filename extension .css Internet media type text/css Developed by World Wide Web Consortium …   Wikipedia

  • Aural Cascading Style Sheets — (ACSS) are the part of Cascading Style Sheets that makes a website more accessible to visually impaired and screen readers. The advantages of Aural Style Sheets are the convenient to screen readers. ACSS can be applied in devices like home… …   Wikipedia

  • Web page — A screenshot of a web page on Wikipedia A web page or webpage is a document or information resource that is suitable for the World Wide Web and can be accessed through a web browser and displayed on a monitor or mobile device. This information is …   Wikipedia

  • Development of Windows Vista — This article is part of a series on Windows Vista New features Overview Technical and core system Security and safety Networking technologies I/O technologies Management and administration Removed features …   Wikipedia

  • Tableless web design — Cascading Style Sheets CSS Animations Dynamic CSS Comparison of layout engines Comparison of stylesheet languages Internet Explorer box model bug CSS Zen Garden The Zen of CSS Design CSSTidy Style sheet Tableless web design Holy Grail (web… …   Wikipedia

  • History of the Opera web browser — MultiTorg Opera The history of the Opera web browser began in 1994 when it was started as a research project at Telenor, the largest Norwegian telecommunications company. In 1995, the project branched out into a separate company named Opera… …   Wikipedia

  • Dynamic Cascading Style Sheets — Cascading Style Sheets CSS Animations Dynamic CSS Comparison of layout engines Comparison of stylesheet languages Internet Explorer box model bug CSS Zen Garden The Zen of CSS Design CSSTidy Style sheet Tableless web design Holy Grail (web… …   Wikipedia

  • Wikipedia:Manual of Style — This guideline is a part of the English Wikipedia s Manual of Style. Use common sense in applying it; it will have occasional exceptions. Please ensure that any edits to this page reflect consensus. Shortcuts …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”