The difference between script tag and noscript tag in html

黄舟
Release: 2017-06-30 10:31:24
Original
2331 people have browsed it

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>
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!