33

I am using few facebook social plugins and I am using the meta header. When validating the page, the W3C validator is throwing the error -> "Error: there is no attribute "property".

I am using the XHTML Transitional doctype - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Pls Suggest if I have to change the doctype to something else.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
Castor
  • 1,843
  • 3
  • 15
  • 13

3 Answers3

43

Facebook's plugins use Open Graph, which is built on RDFa. It's RDFa that adds the property attribute to elements. Without this addition, plain HTML has no such attribute. (If you ask me, it's a strange design to add a new attribute without namespacing it, and to re-use half of a <meta> tag. But no-one did.)

To validate XHTML-with-RDFa, you'll need the DOCTYPE:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">

This means you will have to be writing valid XHTML 1.1. More

bobince
  • 528,062
  • 107
  • 651
  • 834
  • 1
    You are a genius indeed! My full header now looks like this (sorry, no markup). ` ` – Stefan Hoth Mar 15 '11 at 11:14
  • 15
    Ugh! Facebook must have had a very junior programming team! They openly state that "Developer simplicity is a key goal of the Open Graph protocol" adding a link to a slideshow (http://www.scribd.com/doc/30715288/The-Open-Graph-Protocol-Design-Decisions) in which it says that reusing the – Louis Somers Jul 31 '11 at 21:15
  • @StefanHoth did you manage to validate with that code? When I run it through W3C's validator I get: **Error: value of fixed attribute "version" not equal to default** – Steven Garcia May 26 '12 at 15:17
  • 1
    @StevenGarcia Yes. Checkout my website to see it in action http://validator.w3.org/check?uri=stefanhoth.de&charset=%28detect+automatically%29&doctype=Inline&group=0 – Stefan Hoth May 27 '12 at 12:03
  • Thanks for following up on this - I will take a closer look at it – Steven Garcia May 28 '12 at 11:06
  • 1
    Your link to rdfa.org is dead, maybe the [spec at w3c](http://www.w3.org/TR/rdfa-lite/) will suffice? – BryanH Oct 04 '12 at 22:37
5

In order for a document to claim that it is a conforming HTML+RDFa document, it must provide the facilities described as mandatory in this section. The document conformance criteria are listed below, of which only a subset are mandatory:

  1. All document conformance requirements stated as mandatory in the HTML5 specification must be met.
  2. There should be a version attribute on the html element. The value of the version attribute should be HTML+RDFa 1.0 if the document is a non-XML mode document, or XHTML+RDFa 1.0 if the document is a XML mode document.
  3. There may be a link element contained in the head element that contains profile for the the rel attribute and http://www.w3.org/1999/xhtml/vocab for the href attribute.

Example:

<html version="HTML+RDFa 1.1" lang="en">
  <head>
    <title>Example Document</title>
  </head>
  <body>
    <p>Moved to <a href="http://example.org/">example.org</a>.</p>
  </body>
</html>
Paul D. Waite
  • 96,640
  • 56
  • 199
  • 270
albert
  • 8,112
  • 3
  • 47
  • 63
3

As Open Graph suggests, if you're using HTML5, you're better off just using a prefix attribute like this:

<!doctype html>
<html prefix="og: http://ogp.me/ns#">
  <head>
    <title>HTML5 site</title>
    <meta property="og:title" content="The Rock" />
  </head>
  <body>
  </body>
</html>

You can leave the doctype as is and it will validate.

This approach has also been recommended by an Open Graph developer.

Community
  • 1
  • 1
Timofey Drozhzhin
  • 4,416
  • 3
  • 28
  • 31