10.07.2017 Views

246996016-HTML5-Step-by-Step

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Creating Styles for Nested Tags 91<br />

Creating Styles for Nested Tags<br />

Sometimes you might want to apply a specific formatting only when one tag is nested<br />

within another. For example, perhaps you want a bulleted list that’s nested within another<br />

bulleted list to use a different bullet character.<br />

If you simply created a rule for the entire tag, all text to which this tag has been applied<br />

would be formatted the same way. For example, if you created a style for the tag,<br />

all bulleted items would use the same bullet character. Instead, you must specify that<br />

you want to apply a rule only to the nested tag. To do this, instead of using a single style<br />

name at the beginning of the rule, specify that the item is nested <strong>by</strong> listing the parent<br />

style name followed <strong>by</strong> the descendent (child) style name. For example, to use round bullets<br />

for all bulleted lists that are nested within numbered lists, specify the following:<br />

ol ul {list-style-type: circle}<br />

This technique works with multiple nested levels. For example, to apply this formatting<br />

only to bulleted lists nested within other bulleted lists that are nested within numbered<br />

lists, specify the following:<br />

ol ul ul {list-style-type: circle}<br />

You can do this with any text attributes, not just those pertaining to the bullet or number<br />

type. For example, to make all the bold text that appears in unordered lists appear blue,<br />

specify the following:<br />

ul b {color: blue}<br />

In this exercise, you will apply different bullet characters to a nested list <strong>by</strong> creating styles<br />

in the area of a document.<br />

SET UP Use the index.htm file in the practice folder for this topic. This file is located<br />

in the Documents\Microsoft Press\<strong>HTML5</strong> SBS\06Styles\CreatingNested folder. Open<br />

the index file in Notepad and in Internet Explorer.<br />

1. Examine the index file in Internet Explorer.<br />

Notice that the first-level bullet characters are discs, the second-level bullet characters<br />

are circles, and the third-level bullet characters are squares.

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

Saved successfully!

Ooh no, something went wrong!