![]() ![]() Let's put the script tag inside the HTML head element. Script tag with JavaScript Code in Element Let's cover all of this one by one along with code examples to help you understand them. You can use script tag inside an HTML web page to add JavaScript code in the following ways: Now that we know about the tag which is used to include JavaScript code in a webpage, let's see the various different ways in which we can do so. src URL It specifies the uniform source locator(URL) of a file that contains the script. charset charset It specifies the type of character encoding used in the script deferįalse It specifies whether the browser continues parsing the web page or not. Generally, text/javascript value is used. Text/VBScript It specifies the Multipurpose Internet Mail Extensions (MIME) type of script. There are five attributes of script tag which are listed below in the table: Attributes Values Description asyncįalse It specifies whether the script should be executed asynchronously or not. Similarly, we can use the tag to directly add the JavaScript code too, like this: Script tag Attributes and its Usesįollowing is the basic syntax of using a tag: JavaScript is the default scripting language for most of the browsers. The script tag provides a src attribute that allows us to add a reference to an external script file. The script tag can contain either scripting statements or refer to an external JavaScript file. When an HTML document is loaded with the tag in the web browser, the browser processes the content enclosed inside the script tag as JavaScript code. ![]() The JavaScript code can be inserted in HTML file by using the HTML tag. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |