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

Chapter 3. HTML Optimization > How to Optimize Your HTML

How to Optimize Your HTML

Optimizing HTML is a matter of using the fewest number of bytes to deliver a valid page that renders properly. There are a number of techniques you can use to shrink your HTML. These include removing whitespace, omitting optional closing tags and quotes, removing redundant tags and attributes, cutting comments, and minimizing HTTP requests. This last point is important to keep in mind. We'll delve more deeply into graphics in Chapter 12, “Optimizing Web Graphics.” First, let's start with the DOCTYPE declaration.

Step 1: Choose the Right DOCTYPE

As far as speed goes, there are two things to consider when choosing a DOCTYPE and coding style: DOCTYPE switching and parsing speed. By now you've seen the three DTDs you can use at the top of HTML documents (see Chapter 5, “Extreme XHTML” for details). Depending on the DTD that you choose and some internal parameters the browser developers have chosen, browsers switch to one of two or three “modes” to render your HTML document: standards, almost standards, and quirks modes. For more information on “almost standards” mode, see http://www.mozilla.org/docs/web-developer/quirks/doctypes.html.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint