DOCTYPE declaration of HTML

Asked

Viewed 569 times

5

By the standards of the W3C we must declare so: < ! DOCTYPE html >, however I saw on a site that they declared only this: < ! DOCTYPE >, the semantic value is lost or the browser reads the file normally as HTML5?

2 answers

5


According to the specification needs to be complete.

Browsers usually accept without because they try to give compatibility to poorly written code, but it’s wrong. And it may not produce the expected result, as it can interpret as it pleases when there is no statement according to the specification. He tries to help you, but it might get in the way.

Right:

<!DOCTYPE html>
  • 1

    The question is good and was already negative.

-4

There is no obligation, the use depends on its purpose, but without "html" the browser will understand that it is the default HTML and not another old one like "XHTML 1.1 DTD".

  • 4

    There is a requirement yes, otherwise it is not HTML5. In XHTML 5 it can be omitted, but at the risk of being interpreted in quirks mode. Here’s a legal summary: http://www.doctype.org/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.