I am writing an HTML page and noticed that the HTML header tags are not exactly consistent. Some of them require closing tags and some do not.
For example, script
tag does require a closing tag but meta
does not. Now I wonder why?
The script
tag is not an empty (non-closed) tag because it sometimes contains content (Javascript code), but the meta
tag never does.
There are two ways to put Javascript in a webpage. The first way is including an external file:
<script src="path/to/my/script.js"></script>
The second way is to put the Javascript right inside the HTML file, like this:
<script>
Javascript goes here
</script>
So sometimes, the script
needs to have content. But the meta
tag, on the other hand, only needs to provide a small amount of information about the current page, so an empty tag suffices.
I believe it is just an arbitrary reason having to do with the system which the current system was built on...
"In case anyone's curious, the ultimate reason is that HTML was originally a dialect of SGML, which is XML's weird older brother. In SGML-land, tags can be specified in the DTD as either self-closing (e.g. BR, HR, INPUT), implicitly closeable (e.g. P, LI, TD), or explicitly closeable (e.g. TABLE, DIV, SCRIPT). XML of course has no concept of this."
from: https://stackoverflow.com/a/3327807/773263
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With