Skip to main content

What is a Style Sheet

A Style Sheet is a collection of style rules that that tells a browser how the various styles are to be applied to the HTML tags to  present the document. Rules can be applied to all the basic HTML elements, for example the <p> tag, or you can define you own variation and apply them where you wish to.

Why Do They Cascade?

Style Sheets let you selectively override previous defined Styles. For example a Web site might be using a standard Style Sheet but certain Web pages can have an additional Style Sheet that can override styles that have been defined in the standard Style Sheet.

Where are Style Sheets stored?

Style Sheets can be external or internal to your Web site and/or external or internal to your Web pages. A Style Sheet is a text file that is stored on any Web server, within the same location as your Web pages or a Style Sheet can also be included as part of your Web page.

There are three types of Style Sheets:

  • Embedded: the style rules are included within the HTML at the top of the Web page - in the head.

  • Inline: the style rules appear throughout the HTML of the Web page - i.e. in the body.

  • Linked: The style rules are stored in a separate file external to all the Web pages.

Style sheet precedence is: inline over embedded over linked. However, some browsers treat linked style sheets as more important than embedded. It is important to test your various style sheets and Web pages on as many browser as possible before you commit to authoring a large Web site.