<script> tag

HTML <script> tag

The <script> tag runs a client-side script which is called as JavaScript. It is easier to place your script within the HTML document using this tag.

Depending on your requirement, you can run scripts to change the behavior of your HTML document.

<script type=”text/javascript”>….</script>


  document.getElementById("test").innerHTML = "Learn CSS from TutorialBrain";

How Browser will display


Difference between HTML4.01, XHTML and HTML5

None None New async attribute is added in HTML5.

Attributes used with <script> tag

Attribute Description
async defines that the script is executed asynchronously (only for external scripts)
charset defines the character encoding used in an external script file
defer defines that the script is executed when the page has finished parsing (only for external scripts)
src defines the URL of an external script file
type defines the media type of the script
xml:space defines whether whitespace in code should be preserved( It is deprecated now and you should avoid using this attribute.)

Global Attributes

The <script> tag supports Global attributes.

Event Attributes

The <script> tag supports Event attributes.

Supporting Browsers

supporting-browsers for tags

Related Tags

<noscript> tag.

Tutorials for all brains!