Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I really need xmlns or prefix to use opengraph meta tags?

On http://ogp.me it's suggested that I use:

<html prefix="og: http://ogp.me/ns#">

Confusingly, on that same page they link to an article about technical design decisions that uses this:

<html xmlns:og="http://opengraphprotocol.org/schema/">

I took a look at the source for facebook.com, twitter.com, and stackoverflow.com and all use Opengraph meta tags but none include any xmlns or prefix declaration.

What gives?

like image 673
Eaten by a Grue Avatar asked Sep 17 '25 13:09

Eaten by a Grue


1 Answers

My answer is basically a rehash of answers given here and here. You should specify a namespace with the prefix attribute (newer, more recommended method) or the xmlns declaration (equivalent; an older reminiscent of xhtml). For Opengraph metatags, however, you may choose to omit the prefix/declarations as Opengraph (among others) is widely recognized:

RDFa users can use these prefixes without having the obligation of defining the prefixes in the HTML code

In spite of that, explicit is better than implicit, as they say in our profession. It is better to announce you are using Opengraph metatags then just use them and expect whoever reading the tags to infer that based on the experience that "oh, if I ever see the 'og' prefix, it probably stands for Opengraph" – although most people will do just that. The suggestion to declare a prefix is a very good one and you should follow it. One of the reasons is that it will make it easier to distinguish Opengraph 'og' tags than other, future 'og' tags that might be more popular in the future.

To conclude, you may choose any of the three methods: prefix, xmlns or nothing at all, with preference to the first.

like image 92
MrMister Avatar answered Sep 21 '25 13:09

MrMister