views:

82

answers:

7

Viewing the html source for Googles Privacy Page the header is:

<!DOCTYPE html>
<html lang="en">
  <meta charset="utf-8">
  <title>Google Privacy Center</title>
  <link rel="stylesheet" href="//www.google.com/css/privacy.css">
  <h1><a href="/"><img src="//www.google.com/intl/en/images/logo_sm.gif" alt="Google"></a> Privacy Center</h1>

I noticed there is no body tag here or in the footer. Also, no ending </html>.

Is this valid markup?

+3  A: 

The validation page from validator.w3.org says it's valid HTML5.

But note that Google doesn't really care if their pages are valid markup or not, as long as they display correctly. Google's main page (google.com) is riddled with invalid markup.

NullUserException
A: 

If you run it through the W3C validator you get that This document was successfully checked as HTML5!.

Arve Systad
A: 

It is valid HTML5.

However, it is not XHTML.

SLaks
*"However, it is not XHTML."* Nor does it claim to be.
T.J. Crowder
@T.J.: Correct. My point is that since it's not XHTML, it doesn't need closing tags.
SLaks
+3  A: 

HTML5 (which is what they're declaring that page as) allows you to omit a lot of stuff. For instance, the body tag's start and end tags are both optional, as is the ending html tag (ref).

The validator says it's valid, but the validator's HTML5 support is also still experimental. YMMV

T.J. Crowder
+1  A: 

Reading W3C HTML5 Spec syntax tag omission :

A body element's start tag may be omitted if the element is empty, or if the first thing inside the body element is not a space character or a comment, except if the first thing inside the body element is a script or style element. A body element's end tag may be omitted if the body element is not immediately followed by a comment.

An html element's end tag may be omitted if the html element is not immediately followed by a comment.

Funny thing is that the editor of the document is Ian Hickson of Google, Inc.

zaf
+3  A: 

HTML allows to omit certain start and/or end tags:

Some HTML element types allow authors to omit end tags (e.g., the P and LI element types). A few element types also allow the start tags to be omitted; for example, HEAD and BODY. The HTML DTD indicates for each element type whether the start tag and end tag are required.

If you examine a document type definition like the one of HTML 4.01, the elements are declared with the element declarations <!ELEMENT … >. And within such an element declarations, two characters specify whether the start or end tag of an element can be omitted. See the definition of P for example:

<!ELEMENT P - O (%inline;)*            -- paragraph -->

Here the - after the element name P denotes that the start tag is required and the O denotes that the end tag may be omitted. Another example, the HEAD element:

<!ELEMENT HEAD O O (%head.content;) +(%head.misc;) -- document head -->

Here the two O specify that both the start and end tag can be omitted.

Omitting both tags on elements is only possible as such elements are implicit in their context. In case of HEAD, the content model of the parent element HTML is specified as follows:

<!ELEMENT HTML O O (%html.content;)    -- document root element -->

Where the parameter entity html.content is defined as follows:

<!ENTITY % html.content "HEAD, BODY">

That means the content model of HTML is implicitly defined as HEAD followed by BODY.

You can take a look at the index of HTML 4.01 elements to see what tags of what elements can be omitted.

Gumbo
Thanks for the detailed explanation.
Yehonatan