Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Omitting optional tags of html

Tags:

html

I just read this article from Google. I always thought that closing tags is important to keep html documents clean and make them machine-readable. But they recommend the opposite.

What do you think about this?

like image 990
taicki Avatar asked Dec 08 '22 05:12

taicki


2 Answers

Google are in a somewhat unusual situation in that they serve so very many copies of their main search pages that any tiny saving in page size soon add up. This means for them it's economical to make their pages smaller by removing close tags and whitespace, at the cost of making them harder to maintain.

You aren't Google; it's unlikely to pay off for you. You'll notice the Google page you link to itself doesn't omit the tags it recommends, because it's not one of the critical pages that Google serves a lot of. Compare that to the extreme minification of www.google.com front page.

Use gzip/deflate compression and you'll already get mostly minimal transfer size; reducing markup further is a desperate measure which unless you're serving loads will be a premature optimisation.

like image 158
bobince Avatar answered Dec 29 '22 11:12

bobince


It depends entirely on your doctype. If you use HTML 4 transitional, then yes, you're fine leaving off end tags. If you use XHTML or HTML 4 strict, then no, close your tags.

like image 39
Randolpho Avatar answered Dec 29 '22 11:12

Randolpho