[Home]External stylesheet

HomePage | RecentChanges | Preferences | Newbie Help

Category CSS FAQ

An external stylesheet is very useful if your site has many pages using CSS to define colours, layout etc. Instead of having an inline sheet, the web browser reads an external file (which contains the CSS info) and uses that to display the page on-the-fly. Not only does this make your HTML code a lot cleaner, especially for bigger stylesheets, it also allows you to change the look and feel of your site by only editing one file! (Us webmasters are a lazy bunch!)

<link rel="stylesheet" href="filename.css" type="text/css">

Sure, that is one of the advantages of CSS. The C stands for Cascading, which basically means you may have a 'flow' of different styles which can, if necessary, inherit attributes from the parent. For example, you may wish to have a certain font size for your <P> tags, you define this in an external stylesheet. However, you want ONE Paragraph to be slightly smaller but to have all the same properties as the others, color, font etc.. You could do this by adding an Inline style to that <p> tag:

<p style="font-size: 8pt;">affected text</p>

Using this method you can mix external with inline to give the desired results.

You can also offer "alternate styles" using two or more stylesheets. In theory, the browser should ask the user which stylesheet to use. In practice, it doesn't! You can find more on this, and the mix of external and inline, on the Multiple style sheets page.

Comments --
HomePage | RecentChanges | Preferences | Newbie Help
This page is read-only | View other revisions
Last edited September 3, 2001 1:40 pm (diff)

This FAQ is happily hosted by Betadome Digital Media