Question

In <body>, controlled vocabularies may be initialized as follows:

<!DOCTYPE html>
<html
  lang="en"
  xml:lang="en"
  xmlns="http://www.w3.org/1999/xhtml"
>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title></title>
</head>
<body prefix="
  bibo: http://purl.org/ontology/bibo/
  cc: http://creativecommons.org/ns#
  dc: http://purl.org/dc/terms/
  foaf: http://xmlns.com/foaf/0.1/
  schema: http://schema.org/
">

Is it acceptable (and a good programing practice) to take a similar approach to using controlled vocabularies in <head>? For example:

<!DOCTYPE html>
<html
  lang="en"
  xml:lang="en"
  xmlns="http://www.w3.org/1999/xhtml"
>
<head prefix="
  bibo: http://purl.org/ontology/bibo/
  cc: http://creativecommons.org/ns#
  dc: http://purl.org/dc/terms/
  foaf: http://xmlns.com/foaf/0.1/
  schema: http://schema.org/
">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta dc:author content="fname_lname" />
<meta schema:dateCreated content="yy-mm-dd" />
<meta bibo:Website href="http://www.example.com" />
<link foaf:Person href="https://plus.google.com/u/0/_Google_mbox_string_/about" rel="publisher" />
<title></title>
</head>
Was it helpful?

Solution

Yes, you can use prefix on any element. The prefixes will apply to descendant elements; so if you specify prefix on head, you can’t use those prefixes for elements in body.

If you want to use the same prefixes in the whole document, you might want to use the html element.

Just in case you don’t know: You don’t have to specify the prefixes for vocabularies defined in the RDFa Core Initial Context. As long as you use the registered prefixes (and you don’t define these prefixes for something else in your document), you can use foaf, schema etc. without using prefix/vocab.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top