开发者

Google privacy page html invalid

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/int开发者_如何学Gol/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?


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


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.


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.


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.


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


It is valid HTML5.

However, it is not XHTML.


Yes this is HTML5

http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fwww.google.com%2Fintl%2Fen%2Fprivacy.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜