Playing HTML Jenga I recently had a peek at Google's source code and was surprised to see that their HTML seemed invalid! The first thing I noticed was the lack of closing tags on both the <body> and the <html> tags! I tried this out myself and ran it through a validator. The following code passed as being valid HTML5: <!DOCTYPE html> <html> <head> <title>Lorem Ipsum</title> </head> <body> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in</p> This piqued my curiosity enough for me to ask: How many tags can I remove without the whole thing falling apart? A game I like to call HTML Jenga Next, I removed the closing tags on the two paragraphs. Again, the following code still passes as valid HTML5: <!DOCTYPE html> <html> <head> <title>Lorem Ipsum</title> </head> <body> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in Next thing to go was the closing tag for the head. Again, still valid! Cut to the chase! In the end, I removed the <html>, <head> and <body> tags completely and this still passed as valid html! Surprisingly, the only two tags that were required were the doctype definition and the <title>. <!DOCTYPE html> <title>Lorem Ipsum</title> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in Even more surprising was the fact that Chrome and Safari both knew what to do with this code and were smart enough to insert the missing tags into the DOM as the page was loaded. (You can check this yourself using the Developer tools). Any tags that usually appear in the head, for example <script>, <meta> or <link> tags were all wrapped in a <head> tag by the browser. Similarly, as soon as a page content tag such as a <div> or <p> tag was encountered, the browser was smart enough to close the head and open the body. Playing HTML Jenga with your own website. Playing HTML Jenga was a fun learning exercise and encouraged me to read more about both HTML5 standards and also how modern browsers work. I would have reservations about applying it to a live website though... Google strip out their closing <body> and <html> tags and I guess if Google does it you can be sure that it will be safe for most browsers. However, I've yet to test out the rest of the tag-pruning in older browsers and would not be surprised if they resulted in some strange rendering issues. Also, unless you're dealing with massive volumes of traffic like Google do, there's really nothing to gain from hacking back your HTML for the sake of a few bytes. Also, having written XHTML for so long, I've grown comfortable with closing all of my tags and having markup that is easier to read and follow. Moving back to open HTML tags will take some getting used to. Give this a try and check out the HTML5 specification too!