Authors: Jens Meiert & Kevin Khaw, Google Webmasters
Recommended experience: Basic HTML
A clear way to improve the load time of your site is to decrease the file size of your HTML documents. There are several ways to do this, from rigid compression to acupuncture-like ID and class name changes. Here we’ll have a quick look at an HTML feature you can use to make your markup significantly leaner.
HTML – as opposed to XHTML, even when delivered with the MIME type
text/html – allows authors to omit certain tags. According to the HTML 4 DTD, you can omit the following tags (tags of so-called “void” – empty – elements are marked as strikethrough):
For example, if you have a list of items marked up as
<li>List item</li>, you could instead just write
<li>List item. Or instead of a paragraph that you’d usually close with
</p>, you could just use
<p>My paragraph. This even works with
body, which are not required in HTML. (Make sure you feel comfortable with this before making it your standard coding practice.)
Omitting optional tags keeps your HTML formally valid, while decreasing your file size and making your code look much leaner. In a typical document, this can mean 5-20 % savings. Applying this and a few other techniques in our Privacy Centers, we managed to save about 20 % of the original file size.