<script> HTML Tag

Disclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page. Learn more
What does <script> HTML Tag do?
The <script> element contains code written in a programming language other than HTML or specifies the location of an external script resource. It is most commonly used to add JavaScript and jQuery to webpages either directly or by linking to external .js files.

Empty or Not?

The <script> element has two potential uses. It can define a section of the page written in a scripting language other than HTML. It can also import a script from an external file. In the latter case, the <script> element must have no content.

Default Behavior

By default, the browser will load and run the script while the rest of the content is loading. You can control this using the defer attribute, which forces the browser to finish loading the page first.

Claire is seasoned technical writer, editor, and HTML enthusiast. She writes for HTML.com and runs a content agency, Red Robot Media.

Browser Support for script