C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
HTML Script TagHTML script tag is used to specify client-side script such as JavaScript. It facilitate you to place a script within your HTML document. JavaScript is used for image manipulation, form validation, and dynamic content. The syntax of script tag is given below: <script> //code to be executed </script> Attributes of HTML script tag
Usage of script tag
There can be two usage of HTML script tag:
Embed script code
The script tag can be used within <body> or <head> tag to embed the scripting code. Let's see the example to have script tag within HTML body.
<script type="text/javascript">
document.write("JavaScript is a simple language for TheDeveloperBlog learners")
</script>
Output: JavaScript is a simple language for TheDeveloperBlog learners Let's see the example to have script tag within HTML head tag.
<script type="text/javascript">
function msg(){
alert("Hello TheDeveloperBlog");
}
</script>
Link script fileThe script tag can be used to link external script file by src attribute. It must be used within the <head> tag only. <script type="text/javascript" src="message.js" /> Supporting Browsers
Next TopicHTML section tag
|