Introduction to Cascading Style Sheets


CSS : HTML :: Form : Content

CSS is designed to allow you to separate the "Form" of your web pages from their "Content".  Actually, its really more along the lines of Presentation vs. Content.  CSS may be able to make a pile of poo look fantastic, but it will still be a pile of poo.  For the rest of this introduction, we'll try to focus on applying CSS styles to gibberish. So, when you're asked to create some html is can be absolute random key presses as such : aslkha asldkfh asdf awle.

Why Cascading

With CSS, style information can be specified in a number of ways.  Styles can be witen inside a single HTML element, inside the <head> element of an HTML page, or in an external CSS file.  You can even reference multiple external sytle sheets inside of a single HTML page. Cascadeing Order = What style will be used when there is more than one style specified for an HTML element?

All styles will "cascade" into a new "virtual" style sheet in the following order:

  1. Browser default
  2. External style sheet
  3. Internal style sheet (inside of the <head> tag)
  4. Inline style (inside an HTML element)

Thus, an inline style has the highest priority, which means that it will override a style declared inside the <head> tag, in an external style sheet, or in a browser.

The Presentation Problem

HTML tags were originally designed to define the content of a document. They were supposed to say "This is a header", "This is a paragraph", "This is a table", by using tags like <h1>, <p>, <table>, and so on. The layout of the document was supposed to be taken care of by the browser, without using any formatting tags.

As the two major browsers - Netscape and Internet Explorer - continued to add new HTML tags and attributes (like the tag and the color attribute) to the original HTML specification, it became more and more difficult to create Web sites where the content of HTML documents was clearly separated from the document's presentation layout.

To solve this problem, the World Wide Web Consortium (W3C) - the non profit, standard setting consortium, responsible for standardizing HTML - created STYLES in addition to HTML 4.0.

The Benefits of CSS

The Drawbacks of CSS



previous | index | next