HTML5 Doctype with strict
Asked Answered
M

1

14

I want a strict but fully compatible html5 alternative to:

<!doctype html>

Basically I want to ensure the use of closing tags just to keep everything well readable, consistent and highlighted clearly in editors.

The answer to this question is to HTML 5, as XHTML-1.0-strict is to HTML 4.

Thanks in advance.

Melanie answered 16/5, 2013 at 20:7 Comment(0)
B
16

There is no doctype for "strict" XHTML5 validation. For XHTML5 the doctype is even optional, as the doctype is only for stopping the browser to switch to quirksmode. There is no such quirksmode for XHTML. It is recommended to use the HTML5 doctype (with capitalised DOCTYPE) if you are planning to use it as a polyglot document. In that case you would use the doctype:

<!DOCTYPE html>

However, if you want to validate as if the document is using XHTML style syntax, you can achieve that using the advanced options of the validator.

  1. Go to http://validator.nu
  2. Switch to "text field" in the select box (or point it to your online document but make sure it is served as XHTML not text/html
  3. If using the text field paste in your document. In my case I used the following:

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title></title>
    <meta charset="UTF-8" />
    </head>
    <body>
    <p>test
    </body>
    </html>
    
  4. Select XHTML5 + SVG 1.1 + MathML 3.0 from the Preset field. This will pre fill the scheme as http://s.validator.nu/xhtml5.rnc http://s.validator.nu/html5/assertions.sch http://c.validator.nu/all/

  5. Click Validate

Using my document it will warn about the missing close </p>.

Byng answered 16/5, 2013 at 21:2 Comment(1)
Why "with capitalised DOCTYPE"? I thought that all HTML was case-insensitive.Pucida

© 2022 - 2024 — McMap. All rights reserved.