Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 Doctype with strict

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.

like image 261
Anon343224user Avatar asked May 16 '13 20:05

Anon343224user


1 Answers

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>.

like image 84
David Storey Avatar answered Sep 19 '22 14:09

David Storey