This project has moved and is read-only. For the latest updates, please go here.
1
Vote

html5 doctype causes xmlns attribute to be added

description

Consider this example html skeleton and code snippet:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
</head>
<body> ...</body>
</html>
var doc = new HtmlDocument();
doc.Load("file.html");
doc.Save();
After saving the document, an xmlns attribute is added to the html tag:
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
Expected behavior:
If the html doctype is html5 (<!DOCTYPE html>), the xmlns is not added to the html element, since HTML5 is not XHTML.

Disturbance:
The xmlns attribute causes Visual Studio to mark the meta tag in the example above as an error. This is because singleton tags like meta require a trailing slash in XHTML, but in HTML it is optional.

Workaround:
When providing the doctype in lower case (<!doctype html>), the xmlns attribute is not added to the html tag.

comments