Joel
Joel

Reputation: 6107

HTML Document type and XML namespace

I understand that in order to instruct the browser how to handle HTML page I need to specify a DOCTYPE... For a page that i built with HTML5 I used the following:

<!DOCTYPE html>

When i am viewing other sites that are using the same DOCTYPE, there is an additional definition inside the <html> tag, such as:

<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">

What does the xml namespace do that it is needed inside the HTML tag in addition to the DOCTYPE definition?

Thanks!

Joel

Upvotes: 1

Views: 607

Answers (2)

Floern
Floern

Reputation: 33904

If the xmlns attribute is set, it's a XHTML (XHTML5) document.

This indicates a HTML5 document:

HTTP-Header Content-Type: text/html

<!DOCTYPE html>
<html>

And this indicates a XHTML5 document:

HTTP-Header Content-Type: application/xhtml+xml

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

If the webpage is using XHTML5 an does not have the xmlns attribute, it wont be displayed properly (Firefox would display the XML-DOM instead of the page).

Upvotes: 2

krtek
krtek

Reputation: 26597

HTML5 isn't XML, so the informations in the html tag aren't needed

Upvotes: 0

Related Questions