When HTML5 xmlns is required

I am trying to use various web page builders, and most of them start with this basic structure when I create a new project:

<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>New Web Project</title> </head> <body> <h1>New Web Project Page</h1> </body> </html> 

I could not find an answer about why xmlns should be if it is a regular web page. I know that I can omit it if I want, I wrote HTML5 documents before, and it worked fine without it.

So, when is it really necessary to provide xmlns in an <html> element, and why do composers think it should be there when I create a new project? Is there any value that provides xmlns with the <html> when executing HTML5 in the first place? Are there any benefits from adding it?

+5
source share
2 answers

On a regular HTML5 page, you don’t need this. However, if you want XML-serialized HTML5 (i.e. XHTML), you add an XML namespace. For example, the JSF web framework uses XML-serialized HTML, so there is one reason for using it.

+3
source

The HTML validator at http://w3.org does not complain when the xmlns attribute is not present in the XHTML document. This is because the namespace "xmlns = http://www.w3.org/1999/xhtml " is by default and will be added to the tag, even if you do not include it.

From http://www.w3schools.com/tags/att_html_xmlns.asp

+2
source

All Articles