Why does a "script" require a tag to close, but no "meta"?

I am writing an HTML page and notice that the HTML header tags are not quite consistent. Some of them require closing tags, and some do not.

For example, a closing tag is required for a script tag, but meta not. Now I wonder why?

+6
source share
2 answers

I believe that this is just an arbitrary reason related to the system on which the current system was built ...

β€œIn case anyone is interested, the end reason is that HTML was originally a dialect of SGML, which is an odd older brother of XML. In an SGML space, tags can be specified in DTDs as self-closing (for example, BR, HR, INPUT) , implicitly close (for example, P, LI, TD) or explicitly close (for example, TABLE, DIV, SCRIPT). XML, of course, has no idea about this.

from: fooobar.com/questions/10762 / ...

+2
source

The script tag is not an empty (open) tag because sometimes it contains content (Javascript code), but the meta tag never does.
There are two ways to place Javascript on a web page. The first method includes an external file:

 <script src="path/to/my/script.js"></script> 

The second way is to place Javascript right inside the HTML file, for example:

 <script> Javascript goes here </script> 

Therefore, sometimes the script must have content. But the meta tag, on the other hand, should only provide a small amount of information about the current page, so an empty tag is enough.

+9
source

Source: https://habr.com/ru/post/922951/


All Articles