Home > Article > Web Front-end > The difference between script tag and noscript tag in html
In fact, everyone who has studied web development should know the script tag of HTML. However, if you use framework to develop, these tags are usually automatically generated, and you usually don’t pay attention to them. You pay more attention to the js file in the src path.
Recently when I was writing JSpractice code, I accidentally discovered that there are a lot of things to pay attention to in the script tag.
According to W3C standards, the type attribute in the script tag is required, and src is optional. Although there will be no problem if you don't write type.
XHTML is a little more complicated:
<script type="text/javascript"> //<![CDATA[ var i=10; if (i<5) { // some code } //]]> </script>
There is an optional attribute of defer="defer" in the script tag, which can define the script to be executed after the page is loaded, but... This attribute must be used together with src, otherwise some browsers do not support it. PS: IE 6 also supports this attribute.
The onscript tag will display its content when the browser disables scripts:
<noscript> <p>To better present the page, please turn on scripting.</p> </noscript>
The above is the detailed content of The difference between script tag and noscript tag in html. For more information, please follow other related articles on the PHP Chinese website!