Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an XHTML 5 validator?

Is there a validator specifically for XHTML 5, i.e. the XML serialization of HTML 5? The W3C validator supports the document types:

  • HTML 5 (experimental): which treats as valid various features that are not allowed in XML, such as implicitly closed <br> tags.
  • several XHTML 1.0 and XHTML 1.1 doctypes, which don't recognize the new tags in HTML 5.
like image 786
Mechanical snail Avatar asked Dec 21 '22 08:12

Mechanical snail


2 Answers

You can use Validator.nu (X)HTML5 Validator (Living Validator):

http://html5.validator.nu/

Note that the "living validator" means that since the HTML 5 spec itself is constantly evolving, so does the validator - the results of your validation can change with the passing of time (invalid markup may become valid and otherwise).

Also, note that the W3C Markup Validation Service explicitly states after the validation:

The document located at <...> was successfully checked as HTML5. This means that the resource in question identified itself as "HTML5" and that we successfully performed a formal validation of it. The parser implementations we used for this check are based on validator.nu (HTML5).

So Validator.nu actually is the (X)HTML5 validator.

like image 133
Russ Clarke Avatar answered Dec 28 '22 08:12

Russ Clarke


The W3C validator for HTML 5 in fact does detect and validate XHTML 5:

  • When validating by URI, it uses the content-type provided by the server (XHTML if it specifies application/xhtml+xml).
  • When validating by file upload or direct input, it guesses based on whether an xmlns attribute is present in the file. That is,

This is identified as XHTML (and is therefore correctly marked invalid):

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>test</title></head>
<body><br></body></html>

This is identified as HTML (and is therefore correctly marked valid):

<!DOCTYPE html><html>
<head><title>test</title></head>
<body><br></body></html>

Edit: Apparently they're removing this auto-identification. See this bug.

like image 32
3 revs Avatar answered Dec 28 '22 08:12

3 revs