DEV Community


Discussion on: Why hasn't the 'script' tag gotten a void version, yet? (E.g. 'extscript')

comandeer profile image
Tomasz Jakut

There are two similar concepts: self-closing elements and void elements. In HTML there are only void elements (so elements without the end tag). If some element is not void, it needs an end tag. The script is not void and that's why it needs an end tag.

The situation is different in XML, which allows any element to be self-closing (so having one tag that will be treated as a start and end tag at the same time). If you want to use self-closing elements, you can always serve your site with application/xhtml+xml MIME type. However it would have all the consequences of serving XML (e.g. draconian error handling). The other solution could be to use some templating engine that uses XML as an input, but generates HTML.

Forem Open with the Forem app