What is the prefix attribute for in the html element (tag)?

Asked

Viewed 1,197 times

4

Why do you use the prefix attribute on elements (tag) html? And in HTML5, can I also use it? Thank you!

<html prefix="og: http://ogp.me/ns#">

1 answer

8


The attribute prefix is one of the attributes created by Rdfa (Resource Description Framework in Attributes).

Rdfa is an attribute-level extension for several markup languages, such as HTML and XML. This extension was created to support Web Semantics on web pages. Instead of you having a web page (defined by a file .html or .xml) which informs the browser only how the page should be structured, the Rdfa allows also to insert information about what your website represents, for example: product listing, city creation page, etc.

In this context, the attribute prefix is used so that you can define a semantic vocabulary which will be used on your website. A semantic vocabulary is a definition of structures that will be used and represented on web pages, very similar to data structures in algorithms. You can have, for example, a vocabulary that defines the default structure that represents a Person. A semantic vocabulary quite popular is the schema.org.

But not always just one vocabulary is enough to describe all the semantics of your web page. That’s why the attribute prefix was created. Using it you can have more than one vocabulary on your page. Below I use two vocabularies to describe a Person who owns a favorite 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 attribute prefix in any HTML (and XML) tag, and not just <html>.

Answering your second question:

And in HTML5, I can also use?

Yes, it is possible to use prefix HTML5. See the official standard page Rdfa, the attribute prefix can also be used in XML, HTML4, XHTML1 and XHTML5, among other formats.


References for those who want to delve into the subject:

http://www.ibm.com/developerworks/library/wa-rdfalite/

https://www.w3.org/TR/html-rdfa/

https://www.w3.org/TR/rdfa-lite/#prefix

https://rdfa.info/

https://en.wikipedia.org/wiki/RDFa

https://en.wikipedia.org/wiki/Semantic_Web

Browser other questions tagged

You are not signed in. Login or sign up in order to post.