Cover by Maximiliano Firtman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

XHTML Mobile Profile and Basic

XHTML MP is based on the W3C’s XHTML Basic, and they are almost the same. The W3C has an online mobile validator at http://validator.w3.org/mobile; it accepts XHTML Basic and MP as valid markup.

XHTML Mobile Profile is a subset of XHTML. It is XML-based, so we need to follow the strict rules. If you have never worked with XHTML 1.0 or 1.1 for the Web, let’s analyze the differences compared with working with HTML:

  • The file must have a root element (html tag).

  • Every tag name and tag attribute must be in lowercase.

  • Every attribute value must be enclosed in quotes.

  • Every tag must be closed. This may seem obvious, but it is not; tags like <img>, <input>, and <br> don’t need to be closed in HTML, but they do need to be closed in XHTML. The general rule is to use self-closed tags, like <br />.

  • The tags need to be closed in reverse order. If you open a paragraph and then a link, you must close the link before closing the paragraph.

  • XHTML entities must be well formed. A mandatory space should be &nbsp; and an ampersand character should be &amp;.

  • All attributes must have a value. For example, <option selected> is invalid; you must use <option selected="selected">.

  • The DOCTYPE declaration is mandatory, and the XML opening tag is optional. In fact, for mobile browsers we should not insert the XML opening tag.

Warning

This is not a book about XHTML, CSS, or even JavaScript. I assume you have some basic experience with these markup and programming languages; if not, you will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required