-2

I use this common modern doctype to signify HTML 5 and so does the new site I'm working on.

<!DOCTYPE html>

I don't do anything to the HTML tag ( it's just <html> so I found it strange when I started working on a new site and found they used:

<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">

What exactly is this line doing. The type of HTML being used has already been specified.

Can the xmlns and lang attributes be removed or are they performing some function?

Research

xmlns - xml namespace

Community
  • 1
  • 1
cade galt
  • 3,843
  • 8
  • 32
  • 48
  • 1
    What's the DOCTYPE on this new site? Typically specifying xhtml in the XML namespace would suggest that XHTML was being used, not HTML5... I suppose you could specify an XML namespace for an HTML5 document, and use [XHTML5](http://stackoverflow.com/questions/5558502/is-html5-valid-xml) but that would be fairly rare, in my experience. – Matt Gibson Aug 01 '15 at 15:12
  • 1
    Why not try [Google](https://www.google.com/#safe=off&q=html%20xmlns) and find the [first link](http://www.w3schools.com/tags/att_html_xmlns.asp)? – takendarkk Aug 01 '15 at 15:12
  • @Zen-LeeChai Well, is the document actually XML? If it is, and something's going to parse it, that would be a good reason to use the namespace. If it's not actually XML (e.g. it omits end tags) then it's pretty pointless. – Matt Gibson Aug 01 '15 at 15:17
  • http://stackoverflow.com/questions/5558502/is-html5-valid-xml – cade galt Aug 01 '15 at 17:37

1 Answers1

2

The xmlns attribute specifies the xml namespace of the document. According to W3.org, it is required for XHTML.

The start tag of the root element of the document MUST explicitly contain an xmlns declaration for the XHTML namespace [XMLNAMES]. The namespace URI for XHTML is defined to be http://www.w3.org/1999/xhtml.

See this excellent SO post for more information.

html5 is not entirely XML-based, there it does not need a namespace-declaration.

You can read some information about the lang attribute here: W3 Org on Language Tags. Basically it specifies the target reader language.

Community
  • 1
  • 1
Mischback
  • 843
  • 5
  • 18