Skip to Content
Programming the Mobile Web, 2nd Edition
book

Programming the Mobile Web, 2nd Edition

by Maximiliano Firtman
March 2013
Intermediate to advanced
774 pages
20h 36m
English
O'Reilly Media, Inc.
Content preview from Programming the Mobile Web, 2nd Edition

Chapter 11. CSS for Mobile Browsers

In earlier chapters we discussed the many standards in the mobile CSS world and noted the CSS extensions available in WAP CSS. Whether we decide to use CSS 2.1, CSS3, CSS Mobile Profile, WAP CSS, or nonstandard extensions, it will be just the same; we’ll use CSS at-rules, CSS selectors, and attributes for those selectors. The standards only tell us which ones are supported. What’s more, we will find some browsers that do not render standard styles but do render nonstandard ones.

This chapter is not intended as an introduction to basic CSS; instead, we will focus on features that are specific to or important on mobile devices.

Where to Insert the CSS

The first question to answer is: where should we tell the browser what styles to apply? We have many options:

  • <style> tags inside the XHTML or HTML markup

  • External stylesheets (.css files)

  • style attributes inside the tags

The third option might seem like the most efficient approach, but it is not the best one. That said, there are times when it is useful. For the CSS WAP extensions for form controls described in Chapter 6, for instance, it is easiest to insert inline styles to avoid defining IDs and ID selectors for each control:

<input type="text" name="name" style="-wap-input-format: A*a">

Warning

On BlackBerry devices running Device Software 4.5 or earlier, stylesheets can be disabled from the browser or from a corporate policy.

If the website you are creating is a one-page document, it will be faster to include ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Mobile Applications: Architecture, Design, and Development

Mobile Applications: Architecture, Design, and Development

Valentino Lee, Heather Schneider, Robbie Schell
High Performance Mobile Web

High Performance Mobile Web

Maximiliano Firtman

Publisher Resources

ISBN: 9781449335595Errata Page