04.06.2013 Views

Head First HTML with CSS

Head First HTML with CSS

Head First HTML with CSS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

using a font style<br />

Styling Tony’s quotes<br />

<strong>with</strong> a little italic<br />

Now we’re going to use the font-style property<br />

to add a little pizazz to Tony’s quotes. Remember<br />

the Burma Shave slogan in the <br />

element? We’re going to change the slogan to italic<br />

style to set it off from the rest of the text. To do that<br />

we just need to style the <strong>with</strong> a<br />

font-style of italic, like this:<br />

blockquote {<br />

font-style: italic;<br />

}<br />

Add this new <strong>CSS</strong> rule to the <strong>CSS</strong> in your<br />

“journal.css” file, save it, and give the page a<br />

test drive. You should see the Burma Shave<br />

slogan change to italic; here’s our test drive.<br />

there are no<br />

Q: The text for the is actually inside<br />

a that’s inside the . So, how did this<br />

change the paragraph to italic?<br />

A: Remember, by default most elements get their font<br />

styles from their parents, and the parent of this paragraph<br />

is the element. So the paragraph <strong>with</strong>in the<br />

inherits the italic style.<br />

Q: Why didn’t we just put the text into an <br />

element inside the ? Wouldn’t that do the<br />

same thing and make the italic?<br />

A: Remember that is for specifying structure.<br />

says that a set of words should be emphasized. What<br />

we’re doing is styling a , we are not indicating<br />

that the text in the should be emphasized. So,<br />

while you’re right, on most browsers is styled <strong>with</strong> italic,<br />

it’s not the right way to style the text in the .<br />

Also, keep in mind that the style of could change, so<br />

you shouldn’t count on always being italic.<br />

362 Chapter 9<br />

Dumb Questions<br />

Here’s the new style on the Burma Shave<br />

slogan in Tony’s page. We got slanted text,<br />

just like we wanted.

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

Saved successfully!

Ooh no, something went wrong!