First:
prefix
is one of the attributes defined by the RDFa (Resource Description Framework in Attributes) extension. RDFa is used to implement the Semantic Web in web pages represented in many markup languages, like HTML and XML. Instead of having a web page telling the browser just how it should be structured, now you can also tell it what the page represents, like a Person, a List of Products, etc.
And for you to be able to semantically represent data on your web page, you need to use a semantic vocabulary, which tells the browser exactly that: what's being represented in your page. A popular semantic vocabulary is schema.org.
But sometimes a singular semantic vocabulary cannot represent and describe all of your web page. That's where the prefix
attribute comes in:
What does the prefix
attribute do?
The prefix
attribute allows you to specify one or more semantic vocabularies being used. The following example uses two vocabularies to represent a Person that has a favorite Animal: schema.org and vocab.org.
<p vocab="http://schema.org/" prefix="ov: http://open.vocab.org/terms/" resource="#manu" typeof="Person">
My name is <span property="name">MY_NAME</span>
and my telephone is <span property="telephone">MY_TELEPHONE</span>.
My favorite animal is the <span property="ov:preferredAnimal">FAVORITE_ANIMAL</span>.
</p>
Can I write <html prefix="og:http://ogp.me/ns#">
instead of <html prefix="og: http://ogp.me/ns#">
or would that be a syntax error?
Besides from not being able to find any examples on the web using the former syntax, from the specification of the RDFa Core you can see that at least one space is indeed mandatory:
prefix
a white space separated list of prefix-name IRI pairs of the form
NCName ':' ' '+ xsd:anyURI
Can I include multiple prefix
attributes for any given HTML tag?
Yes, you can. From the specification of the prefix
attribute given above, and from lots of examples given on the specification of the RDFa Core, the following is allowed:
<html
prefix="foaf: http://xmlns.com/foaf/0.1/
dc: http://purl.org/dc/terms/"
>
<!-- your page -->
</html>
If this prefix
tag is not part of the HTML spec, how would submitting a page containing this attribute to a code validator ever result in my code being standards compliant?
As mentioned by @wensveen, HTML5 supports the RDFa attributes out-of-the-box.