nonopolarity
nonopolarity

Reputation: 150956

Is the "xmlns" in <html xmlns= ...> needed when the page is served as HTML 4.01?

I like to serve the page as HTML 4.01, because XHTML is not really taken as XHTML in some browsers anyway, but Facebook's OpenGraph meta tags requires:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:og="http://ogp.me/ns#"
      xmlns:fb="http://www.facebook.com/2008/fbml">

but since the DOCTYPE of the page is not XHTML, does it matter if the xmlns are there, and should the page be made into DOCTYPE XHTML instead?

(actually, if the page is HTML, the xmlns is kind of confusing, as it is not really XML, but the Facebook page doesn't talk about how to add the meta tags in a page that is HTML 4.01)

Upvotes: 4

Views: 1211

Answers (3)

Pedro Correia
Pedro Correia

Reputation: 813

For HTML 4.01 Strict:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

For HTML 4.01 Trasitional:

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

The xmlns stuff you see in the facebook example are XML namespaces and their purpose is to allow the developer to include custom tailored information to HTML documents.

Think of it like folders in a filesystem.

So when facebook declares:

xmlns:fb="http://www.facebook.com/2008/fbml"

They are defining a "folder" in which their custom tags/attributes/properties are stored, so:

<meta property="fb:admins" content="USER_ID"/>

...where the important part is "fb:admins" is the same as having this on your hard drive:

/fb/admins.txt 

which contains the USER_ID value.

So it's just a way to keep data organized and separated.

Hope this clears things up for you.

Upvotes: 3

jesse reiss
jesse reiss

Reputation: 4579

It won't be valid HTML 4.01 if you add xmlns attributes, but it most likely won't affect the rendering.

I wouldn't use HTML 4.01 if I was you. HTML 5 is the new standard, and you should use it.

Upvotes: 2

Pedro Correia
Pedro Correia

Reputation: 813

Those are XML namespace definitions they exist as a way to avoid collisions in XML element names.

Since this is facebook's protocol, they are the ones that define the namespaces.

It has "nothing" to do with how the page is served.

Upvotes: 0

Related Questions