Should prefixes be used in HTML5 elements?

Asked

Viewed 171 times

1

I noticed in the HTML5 documentation that the use of the attribute is still allowed xmlns in the root element (tag) html. This attribute, according to my study, gives a "qualified unique name" to the element associating to the namespace (value of the attribute), not only for it, but for all its other child elements that do not possess another statement of the attribute xmlns different. It doesn’t matter if the attribute has a present prefix (xmlns:prefixo="url") or not (xmlns="url"). Remember that the address used to identify the namespace, is not used by parser to seek information. The sole purpose is to give the namespace a "qualified unique name". Phew! Question: Should we still use prefixes in HTML5 elements (tags)? Is there a real example of usage in HTML5? It seems to me that it still exists because of the natural process of transition between languages, or else it wouldn’t even be there anymore, is it true? Thank you!

<!DOCTYPE html>
<html xmlns:book="http://www.book.com">
   <book:head>
      ...
   </book:head>
   <book:body>
       <book:h1>Title</book:h1>
       ...
   </book:body>
</html>
  • @Bacco :) This is different: here the focus is on the use of prefixes in HTML5 elements. Since xmlns is still allowed in HTML5 and its main goal is to qualify names in elements within a group of elements, there is an incentive to use prefixes in tags. I wanted to make sure that this is it and when I really need to use the prefixes. Thank you!

1 answer

3


The use of this is totally optional, basically there are patterns and they can be "extensible", but it does not mean that you are obliged or not to use something.

We usually use it when we merge some kind of XML markup, but it’s totally geared towards when you will create a more customized pattern (something of its own), summarizing if you want to create a tag with the aim of making your "HTML" visible or usable in other types of technologies besides conventional browsers, now if the site you want to create is well only to browse even use something like this is totally expendable.

There are several projects and patterns that W3C (not to be confused with w3schools) develops, even the XHTML and HTML separation, there was even XHTML2.0 (which if I’m not mistaken was discontinued to support HTML5).

Follow this, if you want to create a web page to browse, stick to basic HTML/HTML5, if you need an advanced markup like pro Open Graph of facebook (as <html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml"> ) so HTML5 normally supports without needing to apply XHTML, basically today HTML5 supports several features that would be XHTML, which makes a lot of things expendable.

Even though there is still a project called XHTML5, in Xhtml you are required to make a "good markup".

To summarize the use of xmlns:book is a namespace, (xmlns stands for Xml Namespace) and will be used to prevent conflicts, as tags that repeat names, this is a solution for XML, but can be applied to XHTML (since it is an XML), assuming you have to use 2 different xml types within HTML and both have some equal tag, there may be problems, in case the namespace is to avoid this type of conflict, then you can associate one XML to one namespace and the other XML to another namespace, This is similar in programming languages that have classes with the same name, so we use namespaces to avoid conflict.

This question is in edit, as soon as possible I will add an example of conflict.

Browser other questions tagged

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