13.07.2015 Views

Beginning CSS: Cascading Style Sheets for Web Design, 2nd ...

Beginning CSS: Cascading Style Sheets for Web Design, 2nd ...

Beginning CSS: Cascading Style Sheets for Web Design, 2nd ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

How to Structure an External <strong>CSS</strong> DocumentExternal style sheets are essentially the same thing as embedded style sheets; the key difference is thatno markup exists in a <strong>CSS</strong> file. When you create an external, independent <strong>CSS</strong> document, it must be createdusing the .css file extension.An external <strong>CSS</strong> document may contain nothing but <strong>CSS</strong> rules or comments. A <strong>CSS</strong> document cannotcontain any markup; see how this is done in the following Try It Out.Try It OutLinking to an External <strong>Style</strong> SheetExample 2-9. To link to an external style sheet, follow these steps.1. Enter the following XHTML document:Selectors and Grouping<strong>Style</strong> SheetRuleSelectorDeclarationPropertyValue2. Save the XHTML document as Example_2-9.html.3. In a new document, enter the following <strong>CSS</strong>:h1, h2, h3, h4, h5, h6 {font-family: sans-serif;color: maroon;border-bottom: 1px solid rgb(200, 200, 200);}4. Save the <strong>CSS</strong> as stylesheet.css in the same folder that Example_2-9.html was saved in.5. Load up the document in a browser. You should see output that looks like Figure 2-6.How It WorksChapter 2: The EssentialsThe embedded style sheet between the ... tags has been replaced with an externalstyle sheet by placing the rules inside the embedded style sheet into their own document, saving thatdocument with a .css file extension, and then linking to the new file by including the elementin the XHTML document. One of the benefits of an external style sheet is that it allows the same style55

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!