1

So as an example, we have this head taken from Facebook's open graph protocol

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

which would be fine with an xhtml doc type. But what about HTML 5? I have searched for answers, including previous stackoverflow questions and came up short. I know that the xmlns attritbute is allowed in HTML5 if its value is exactly "http://www.w3.org/1999/xhtml". But are attributes with prefixes in the format of xmlns:ex allowed under HTML5? And if they are, is the xmlns attribute necessary when using them? I know that the attribute is not necessary if you have no other attributes that use it. Here is practically my same question but the answer doesn't seem to answer the question. And another question asks about HTML5, facebook, and xmlns. There is only one comment that mentions:

Only the xmlns="w3.org/1999/xhtml"; attribute is allowed on . >xmlns:fb="facebook.com/2008/fbml"; is invalid per HTML5. – hsivonen Jul 6 '09 at 12:05

So is that true? You can't use Facebook Open Graph with HTML5?!

Community
  • 1
  • 1
mr.freshwater
  • 56
  • 1
  • 5
  • I know that the xmlns:og attribute is just there to let any visitor of the page know the format of the data and what it means and that facebook would not need it to interpret data that it already expects in a certain format. But I thought that it might be needed for facebook to see when crawling the site and know to look for the data. But I guess it doesn't work as I was thinking it did. – mr.freshwater Feb 02 '13 at 02:57
  • It seems that facebook does not need the xmlns:og attribute to interpret the data and that it is done when someone likes the page/content and is only used when someone likes the content. I was thinking that facebook crawled your page and offered this content to be searched and liked directly through facebook. Is that not the case? – mr.freshwater Feb 02 '13 at 03:01
  • Facebook also fetches this metadata when someone "shares" your URL in a status message. For instance, if I create a new status in Facebook and paste your URL into it, then Facebook populates that status with `og:metadata` fetched from your site to provide a thumbnail / title / and link (etc) under my status message. – potench Feb 02 '13 at 03:23
  • It seems that the xmlns attribute is not needed to parse the data by the creator of the namespace. But back to the original question: is xmlns:ex attributes allowed per the html5 specification? The answer seems to be no. So the only type of data markup (besides data-ex) in html5 is microdata. My solution for the FB open graph data is going to be to just sniff the user agent and echo that data only to FB. – mr.freshwater Feb 03 '13 at 07:42

1 Answers1

0

This seems to be just an example using Facebook's own HTML template to provide context for their open graph meta tags. I don't think you need to follow their doctype (or title for that matter) as it's just providing context for the <meta property="og:..."> property examples.

I've never changed or had an issue with the doctype declaration and I simply use the standard HTML5 <!doctype html> declaration.

You can use the (open graph debugger)[http://developers.facebook.com/tools/debug] to check your work. Here's an example using HTML5 doctype checked against the open-graph debugger.

It still correctly finds the open graph objects, though the loaded page uses the standard HTML5 doctype: <!doctype html>

potench
  • 3,802
  • 1
  • 28
  • 39