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.

Q: That’s pretty cool. So I can set<br />

up different style sheets for different<br />

devices?<br />

A: Yes, you can set up several style<br />

sheets and then link to them all in your<br />

X<strong>HTML</strong>. It’s the browser’s job to grab the<br />

right style sheet based on the media type.<br />

Exercise<br />

there are no<br />

Dumb Questions<br />

Q: Say you have a “handheld” link<br />

and a link that applies to all browsers;<br />

which one gets applied?<br />

A: The handheld browser will grab both<br />

of them. But, assuming the “handheld” link<br />

is below the “all” link, the handheld rules<br />

take precedence, just like we talked about<br />

before <strong>with</strong> the corporate, division, and<br />

lounge <strong>CSS</strong> files.<br />

the box model<br />

Q: So we have screen (computers),<br />

print (print-like media), handheld (mobile<br />

devices and cell phones). What else is<br />

there?<br />

A: Here are a few more: aural (for<br />

speech browsers), Braille (for people<br />

who need tactile readers), projection (for<br />

projected presentations or slides), tty<br />

(for teletypes and terminals), and tv (for<br />

televisions, of course).<br />

In your “chapter10/lounge/print” folder, you’ll find “print.css”. Open up “lounge.html”<br />

in the “chapter10/lounge” folder and add a new link to this style sheet for the media<br />

type “print”. Make sure you also add the attribute media=“screen” to the <br />

element that links to “lounge.css”, so you have one style sheet for the screen, and<br />

one for the printer. Then save, reload the page, and choose your browser’s “Print”<br />

option. Run to the printer to see the result!<br />

<br />

Here’s the printed version. You’ve totally<br />

changed how the page looks when it’s<br />

printed, using <strong>CSS</strong>. That structure versus<br />

presentation thing is really paying off.<br />

Unfortunately, not all browsers<br />

support the media attribute, so if<br />

you didn’t get this result, try a<br />

newer browser.<br />

Optional printer required, not included <strong>with</strong> book.<br />

you are here 423

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

Saved successfully!

Ooh no, something went wrong!