property
vs. rel
:
Both attributes indicate a predicate of a triple, e.g. rel="http://purl.org/dc/terms/creator
, which is the predicate ... has as a creator: ...
.
The difference is, from where they take their object. Slightly simplified, the rules for property
are: The object is taken ...
- from a valid
content
attribute or, if this is not present in the tag,
- (if no
datatype
attr is present in the tag:) from a valid resource
attribute or, if this is not present in the tag,
- (if no
datatype
attr is present in the tag:) from a valid href
attribute or, if this is not present in the tag,
- (if no
datatype
attr is present in the tag:) from a valid src
attribute or, if this is not present in the tag,
- from the inner content of the element started by the tag.
Slightly simplified, rel
differs in two aspects:
- It takes its object only from a
resource
or a href
or a src
attribute.
- It takes its object not only from an attribute of the same tag, but may also take it from descendant tags. The whole mechanism is called "chaining": "This is the main difference between @property and @rel: the latter induces chaining, whereas the former, usually, does not." 1 Usually, but
property
can induce chaining if used with typeof
(cf. 2).
about
vs resource
:
about
is the attribute to indicate the subject of a triple. The rules for resource
are more complicated: It may indicate a subject or an object, and chaining plays a role here, too.
IMHO, chaining is the most complicated and confusing part of RDFa (and does not give you more than syntactic sugar). I would avoid chaining. This is possible by avoiding the attributes rel
, rev
, resource
and typeof
, which brings some further simplification at the same time. Thus, I use only the following attributes:
about
for the subject
property
for the predicate
content
or href
or src
(or the inner content of the element) for the object, following the rules outlined above
lang
for a language tag for object literals, e.g. lang="en"
datatype
for a datatype tag for object literals
prefix
(but only once in a document), so that I can abbreviate URLs by prefixing, e.g. property="dc:creator"
vocab
(rarely and at the most once in a document), so that I can abbreviate URLs implicitly, e.g. property="creator"
.
(And I use the tag <base href="...">
to indicate the URL base value of the document.)
This is a strict, safe, easy-to-use and easy-to-parse subset of RDFa and allows to express any triple you want.