Home > Web Front-end > HTML Tutorial > How to use HTML

HTML's <script> tag is used to specify client-side scripts, which can help us place scripts in HTML documents. You can embed script code within the <script> tag, or use the src attribute to link to an external script file. This article will introduce to you how to use the <script> tag element in HTML. </script>

How to use HTML <script> tag" ></p>
<p><strong>##<script>Attributes of the tag<span style="font-size: 18px;"></script></strong></p>Introducing how to use the <script> tag Before, we need to first understand the attributes of the <script> tag; the attributes of the <script> tag are: <p><p>src attribute: <strong> is used to specify the URL of an external script file and link to the outside script file. <p>type attribute: <strong> Used to specify the media (MIME) type of the script  Description: <p>1. The MIME type consists of two parts: media type and subtypes. For JavaScript, the MIME type is "text/javascript". <p>2. Some values ​​of MIME type are: <p>"text/javascript", "text/ecmascript", "application/ecmascript", "application/javascript", "text/vbscript" . <p><p>async attribute: <strong>This is a Boolean value used to specify that the script is executed asynchronously; only compatible with HTML5. <p>defer attribute: <strong>This is also a boolean value used to indicate that the script should be executed after parsing the document. <p>##<script>Usage of tags<span style="font-size: 18px;"><strong>##<script>There are two ways to use tags. Let’s introduce them in detail below:<p>1. Embed script code in the <script> tag<p><strong>The<script> tag can be used within the <body> or <head> tag. Write script code inside the ;script> tag to embed into the HTML document. Let’s take a look at an example of embedding script code in an HTML document: <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:js;toolbar:false">&lt;script type = &quot;text/javascript&quot;&gt;   
alert(&quot;php中文网\n网址为:www.php.cn&quot;); 
&lt;/script&gt;</pre><div class="contentsignin">Copy after login</div></div></p> Rendering: <p></p><p><br/></p><p style="text-align: center;"><img  src="https://img.php.cn/upload/article/000/000/024/5c18c5a78fd11808.jpg"/ alt="How to use HTML <script> tag" ></p> 2. Use the src attribute to link external script files<p><span   style="max-width:90%"><strong></strong><script> tag can be used to link external script files through the src attribute. Let’s take a look at linking external script files:</span> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:js;toolbar:false">&lt;script type=&quot;text/javascript&quot;  src=&quot;jquery.min.js&quot; &gt;&lt;/script&gt;</pre><div class="contentsignin">Copy after login</div></div>Note: The HTML document in the example and the external script file-jquery.min.js are in the same folder in the same directory:<p><p><p style="text-align: center;">Summary: The above That’s the entire content of this article, I hope it will be helpful to everyone’s study. <img src="https://img.php.cn//upload/image/255/841/681/1545127372769760.jpg" title="1545127372769760.jpg" alt="How to use HTML <script> tag"/> <p></script><p>The above is the detailed content of How to use HTML <script> tag. For more information, please follow other related articles on the PHP Chinese website!</p>                </div>
            </div>
            <div style=

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