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.

#9 Pages for Mobile Devices<br />

Do you want your Web pages to be usable on mobile devices, like cell phones and personal<br />

digital assistants (PDAs)? If you do, then you need to keep some things in mind when creating<br />

your pages. While mobile devices are getting more sophisticated, their support for X<strong>HTML</strong><br />

and <strong>CSS</strong> still varies widely among the various devices. Some support <strong>CSS</strong>, some don’t; some<br />

display X<strong>HTML</strong> really well, others make a mess of it. The best thing you can do is anticipate<br />

potential problems and plan for the future when support will be better.<br />

<strong>First</strong>, remember that you can write a “handheld” specific style sheet by using the media<br />

attribute of the element.<br />

leftovers<br />

<br />

Unfortunately, support for the “handheld” style sheet media type is still limited, so<br />

even if you’ve got a handheld style sheet link in your Web page, that doesn’t mean<br />

the browser on your phone will actually use it. So, you need to keep some general<br />

design techniques in mind so your Web page looks good on both computer<br />

monitors and small devices:<br />

n<br />

n<br />

n<br />

n<br />

n<br />

n<br />

Remember that many mobile services still charge by the amount of data<br />

transmitted to the device. This is a good reason to write simple, correct<br />

X<strong>HTML</strong> and use <strong>CSS</strong> to style your Web pages.<br />

Keep navigation simple and obvious. That means you should use text links<br />

and avoid special scripting effects that require a mouse and keyboard to use.<br />

Scale down your page as much as you can. If you have a handheld style sheet,<br />

use it to reduce your font sizes, margins and padding as much as possible.<br />

Keep in mind that your multi-column layouts will often be ignored on small<br />

devices, so pay careful attention to the ordering of elements in your X<strong>HTML</strong>.<br />

Many mobile devices lack support for frames and pop-up windows, so avoid<br />

these.<br />

Finally, the best solution is always to test your Web pages on as many devices<br />

as you can to know how they truly perform on small devices.<br />

And while support may currently be limited, if you get in the habit now of writing<br />

alternative style sheets for the “handheld” media type, you’ll be well prepared for the<br />

future when there’s more support for them.<br />

To create a style<br />

sheet for mobile<br />

devices, use the media<br />

attribute <strong>with</strong> a<br />

value of “handheld”.<br />

you are here 649

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

Saved successfully!

Ooh no, something went wrong!