views:

1890

answers:

5

Facebook Connect and their "Social Widgets" documentation mention that you need to add an xmlns attribute to your <html> tag on the page where it will be used.

I understand that xmlns is for XML Name-spacing, and have used such with XHTML before. However, with all the recent talk about HTML4 / HTML5, without having read through the entire spec, is the xmlns attribute compatible with valid HTML5? What about HTML4?

If I've looked over an obvious mention of this in the docs, I'm sorry... point it out?

EDIT: A couple docs references/cites: http://developers.facebook.com/news.php?blog=1&amp;story=198 http://wiki.developers.facebook.com/index.php/Facebook_Connect

A: 

is the xmlns property

It's an attribute.

compatible with valid HTML5?

Sort of. It is completely meaningless, but allowed so people can be lazy when porting XHTML.

Remember that HTML 5 is an unfinished draft. These things are subject to change. Don't rush into using HTML 5 unless it offers a serious benefit.

What about HTML4?

Not at all.

David Dorward
Doh! Jacked up my terminology there. Fixed it, thanks!
anonymous coward
Only the xmlns="http://www.w3.org/1999/xhtml" attribute is allowed on <html>. xmlns:fb="http://www.facebook.com/2008/fbml" is invalid per HTML5.
hsivonen
+2  A: 

Actually, the first cited reference discusses adding a xmlns:fb="http://www.facebook.com/2008/fbml" attribute. This is not valid HTML5. It is valid XHTML5. The second cited reference does not mention an xmlns attribute at all.

Note though, that although it is not valid HTML4 or HTML5, it will do no harm.

Alohci
A: 

Is there still no definitive answer to this? With the HTML5 doctype becoming more popular, surely Facebook is working on / has an alternative that will validate as HTML5?

Ashley
@Ashley your "answer" probably should have been made as a comment. Both of the provided answers are acceptable - technically it's valid under "XHTML", and will work just fine on (all?) browsers that support HTML5 anyway.
anonymous coward
A: 

Another Option

"Using the Facebook JavaScript Client Library, you can render XFBML inline on a Facebook Connect site or iframe canvas page, without using XFBML tags."

http://wiki.developers.facebook.com/index.php/Using_HTML_to_Imitate_XFBML

Jesus Saldivar
A: 

I've had the same problem using HTML5 for facebook connect and solved with a small hack on Facebook's JavaScript API.

Read my blog: http://fbml5.blogspot.com/

The method on the dev wiki (mentioned by Jesus Saldivar) has two things which I don't like:

  • it requires an extra javascript call per html tag. My method only needs a html tag.
  • it needs invalid attributes in the tags, so the final html code is invalid. My method uses the user-data attributes to avoid invalid html.

Please tell me what you think of it.

dennisdegryse