Search code examples
javascripthtmltagsdtd

Add Custom HTML Tag by Editing DTD


Sample DTD
The above is a link points to strict.dtd file in w3.org. It contain definition for HTML4 Tags. I want to know that whether it is possible to create my own HTML tag by just editing the DTD (should supported by latest version of all major browsers (eg : chrome/ff/edge)). I found many articles and solutions on creating custom Tags even in stackoverflow. But it make use of JavaScript to create a tag. I want to make it by editing DTD.
for example :

<custom-tag property=value></custom-tag>

I don't want to achieve this using data-* in HTML5

Thanks in advance


Solution

  • Browsers don’t read DTDs or do anything with them. They never have. So no point to make a DTD.

    Instead if you want to use <custom-tag property=value></custom-tag> in your HTML, just do it.

    The W3C HTML Checker (validator) will not report an error for it, because it recognizes all element with names containing a hyphen as being custom elements.