Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 2: The Design of HTML5 > Keeping It Simple

Keeping It Simple

The doctype isn’t the only thing that has been simplified in HTML5.

If you want to specify the character encoding of a markup document, the best way is to ensure that your server sends the correct Content-Type header. If you want to be doubly certain, you can also specify the character set using a <meta> tag. Here’s the meta declaration for a document written in HTML 4.01:

<meta http-equiv="Content-Type" content="text/html; 
charset=UTF-8">

Here’s the much more memorable way of doing the same thing in HTML5:

<meta charset="UTF-8">

As with the doctype, this simplified character encoding contains the minimum number of characters needed to be interpreted by browsers.

The <script> tag is another place that can afford to shed some fat. It’s common practice to add a type attribute with a value of “text/javascript” to script elements:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint