Why is the prefix attribute used in html elements? And in HTML5, can I also use it? Thank you!
<html prefix="og: http://ogp.me/ns#">
Why is the prefix attribute used in html elements? And in HTML5, can I also use it? Thank you!
<html prefix="og: http://ogp.me/ns#">
The prefix
attribute is one of the attributes created by the RDFa Resource Description Framework in Attributes ).
RDFa is an attribute-level extension for many markup languages, such as HTML and XML. This extension has been created to support Semantic Web in web pages. Instead of having a web page (defined by a .html
or .xml
file) that tells the browser just how the page should be structured, RDFa also allows you to enter information about what your web page represents , for example: product listing, city creation page, etc.
In this context, the prefix
attribute is used so that you can define a semantic vocabulary that will be used on your web page. A semantic vocabulary is a definition of structures that will be used and represented in web pages, much like data structures in algorithms. You may have, for example, a vocabulary that defines the default structure that a Person represents. A popular semantic vocabulary is schema.org .
But not always just a vocabulary is enough to describe the entire semantics of your web page. This is why the prefix
attribute was created. Using it you can have more than one vocabulary on your page. Below I use two vocabularies to describe a Person who has a Preferred Pet : schema.org and vocab.org .
<p vocab="http://schema.org/" prefix="ov: http://open.vocab.org/terms/" resource="#manu" typeof="Person">
Meu nome é <span property="name">MEU_NOME</span>
e meu telefone é <span property="telephone">MEU_TELEFONE</span>.
Meu animal de estimação preferido é <span property="ov:preferredAnimal">ANIMAL_ESTIMAÇÃO</span>.
</p>
As can be seen in the example above, you can use the prefix
attribute in any HTML (and also XML) tag, not just <html>
.
Answering your second question:
And in HTML5, can I also use?
Yes, you can use prefix
in HTML5. By viewing the official RDFa default page, the prefix
attribute can also be used in XML, HTML4, XHTML1, and XHTML5, among other formats.
References for anyone who wants to dig deeper into the subject:
#> link