Non-existent html tag & browser rendering

I remember that circa 2012 doing something like: <any>some text</any>
would not be recognized nor be rendered by the browser. Well, now I’ve tested in Safari, Firefox & Chrome and they all render it and also accept CSS, eg. I make it to display as block and it behaves like a normal div element

note: I’m not referring to custom elements / web components

Although it works I believe it’s not a good practice to use a non standard tag, but how bad it could be?

The first thing I will say is: Why?
There are plenty of perfectly good tags that are valid that you can use.
If the element is something special, that there is no tag for, you may use a semantically inert element like div or span, then use the class attribute to define what it is.

As you have seen, how browsers handle invalid HTML changes over time. At one time, something may not work, a later time the same thing does work. What’s to say it can’t happen the other way around? Something that works in a particular browser today, may not work in a years time.
When you use invalid code, all bets are off, you have no guarantee that things will work, or continue to work over time in all or any browser.

6 Likes

Thanks SamA74 for the input. It does make sense, in particular the following quotes:

If the element is something special, that there is no tag for, you may use a semantically inert element like div or span, then use the class attribute to define what it is.

When you use invalid code, all bets are off, you have no guarantee that things will work, or continue to work over time in all or any browser.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.