HTML5 and CSS3, Second Edition

(singke) #1
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Compared to this, the HTML5 doctype is ridiculously simple:


html5_why/index.html
<!DOCTYPEhtml>

Place that at the top of the document, and you’re using HTML5. Of course,
you can’t use any of the new HTML5 elements that your target browsers don’t
yet support, but your document will validate as HTML5.

More-Descriptive Markup


Each version of HTML introduces some new markup, but never before have
there been so many additions that directly relate to describing content. You’ll
learn about elements for defining headings, footers, navigation sections,
sidebars, and articles in Chapter 2, New Structural Tags and Attributes, on
page 13. You’ll also learn about meters, progress bars, and how custom data
attributes can help you mark up data.

Less Cruft


A lot of the elements in HTML5 have been streamlined and have more sensible
defaults. You’ve already seen how much simpler the doctype is, but other
things have gotten easier to type, as well. For example, for years we’ve been
told we have to specify JavaScript <script> tags like this:

<scriptlanguage="javascript"type="text/javascript">

But in HTML5, it’s expected that you’ll use JavaScript for all <script> tags, so
you can safely leave those extra attributes off.

If we want to specify that our document contains UTF-8 characters, we only
have to use a <meta> tag like

<metacharset="utf-8">

instead of the unwieldy and often copied-and-pasted


<metahttp-equiv="Content-Type"content="text/html;charset=utf-8">

Improved User Interfaces


The user interface is such an important part of web applications, and we
jump through hoops every day to make browsers do what we want. To style
a table or round corners, we either use JavaScript libraries or add tons of
additional markup so we can apply styles. HTML5 and CSS3 make that
practice a thing of the past.

Chapter 1. An Overview of HTML5 and CSS3 • 2


Download from Wow! eBook <www.wowebook.com> report erratum • discuss

Free download pdf