10.07.2017 Views

246996016-HTML5-Step-by-Step

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

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

Constructing Style Rules 87<br />

<br />

ul {<br />

list-style-type: square<br />

}<br />

ol {<br />

list-style-type: lower-alpha<br />

}<br />

<br />

Now further suppose that you want these specifications to apply to all the bulleted and<br />

numbered lists in all documents, in your entire Web site. You can create an external<br />

cascading style sheet, and then refer to that style sheet in the section of each<br />

document to which it should apply. For example, here’s the entire text of an external<br />

cascading style sheet (a plain text file with a .css extension) that would apply the specified<br />

rules.<br />

ul {<br />

}<br />

ol {<br />

}<br />

list-style-type: square;<br />

list-style-type: lower-alpha;<br />

It’s the same code that was enclosed within the tag in the previous example.<br />

When style rules appear in a separate file, you don’t need the tag.<br />

A cascading style sheet can get very complex if it includes a lot of rules, but the principles<br />

are always the same as in these examples. The remainder of this chapter explores how to<br />

construct style rules within both embedded and external style sheets.<br />

Constructing Style Rules<br />

An embedded style sheet consists of a two-sided tag placed in the section<br />

of a document. Between the and tags, you define the rules for the<br />

various styles.<br />

A style rule begins with the name of the tag or other element to which the style applies.<br />

For example, if you are creating a rule that will apply to all instances of the tag,<br />

start the rule with h1 (no brackets):<br />

<br />

h1<br />

<br />

No brackets are necessary around h1 because it’s already enclosed in the tag.

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

Saved successfully!

Ooh no, something went wrong!