How are non-standard tags handled by the browser?

I'm reworking legacy code and I see some non-standard tags in there:

<close></close>

      

Since these are not custom elements , but just work like divs

, I tend to remove them and replace with structures like this

<div class="close"></div>

      

In the meantime I am wondering if elements with tags that are not from this list https://www.w3schools.com/tags/ are somehow handled by browsers, and if they require more resources to process or not?

+3


source to share


3 answers


I think it's only interesting to note that unknown elements such as the element <close></close>

in question expose the HTMLUnknownElement

interface
to the DOM.

Otherwise, there is nothing exceptional about how the browser handles them. HTML parsers in browsers parse them into the DOM in the same way as normal known elements.



As for the part of the question of whether unknown elements require more resources to handle, given that the browser doesn't do too much special with them, the browser resource requirements for handling them are no different than what they would be for div

or whatever.

+2


source


Non-standard items are handled in the same way as simple items <div>

.

But this may have a different meaning. For example. <div class="section">

and <section>

has different meanings for some page crawlers (for example, the Google robot).

There might also be some JS code that works with these tags and changing it will break the JS code.



eg. $('close')

won't work with<div class="close">


Html is nothing more than XML, so any tag can be written in HTML with any attributes. It only matters when some tool processes these tags.

0


source


You can read the article for more information: https://www.html5rocks.com/en/tutorials/webcomponents/customelements/

They do not require more resources to process them because of this, like standard-tag

.

Please note that when using non-standard-tag

:

  • No Google will penalize your site for using non-standard HTML tags in an Html document. But when we talk about Google, we are talking about Google bots and search engine results. When bots index or read your page, it checks the document type based on the type that it crawls your site. Basically, by using custom tags that are not standard according to the doctype, you are confusing bots that can reduce the weight of your content and may not appear in search results.

  • You will be better off. But you have to think about cross-browser compatibility, because you are writing all this for the world. It will look different in some browsers, especially IE. So it's good to practice using standard HTML tags.

  • In jquery, the Selector concept is the same for all elements. Again, this can break in IE if you use custom tags.

0


source







All Articles