I want to create something like
In some circumstances, it may look like creating your own tag names just works fine.
However, this is just your browser's error handling routines at work. And the problem is, different browsers have different error handling routines!
See this example.
The first line contains two made-up elements, what
and ever
, and they get treated differently by different browsers. The text comes out red in IE11 and Edge, but black in other browsers.
For comparison, the second line is similar, except it contains only valid HTML elements, and it will therefore look the same in all browsers.
body {color:black; background:white;} /* reset */
what, ever:nth-of-type(2) {color:red}
code, span:nth-of-type(2) {color:red}
test
test
Another problem with made-up elements is that you won't know what the future holds. If you created a website a couple of years ago with tag names like picture
, dialog
, details
, slot
, template
etc, expecting them to behave like spans, are you in trouble now!