Arteqo Consulting

The European Web Agency

Design, brand and digital development


×

Arteqo Consulting Services

Contact Arteqo

×
I have read and accept the terms and conditions

script tag

The script tag, which, when implemented in the code, is written like this - <script>, is an HTML tag that belongs to programming tags. Programming HTML tags are used to insert non-HTML elements inside a document, that is elements that are in other programming languages. These are the tags that allow expanding a document's functions beyond those allowed by HTML and CSS alone.

<script> is used to define a client-side script (JavaScript). The <script> element either contains scripting statements, or it points to an external script file through the src attribute. Common uses for JavaScript are image manipulation, form validation, and dynamic changes of content. This tag is supported in the current version of HTML, which is HTML5.

Browser support

Here you can see whether <script> is supported by a certain browser, and, if yes, starting from which version it is supported.

Browser support for <script>
ChromeFirefoxEdgeOperaSafari
Is supportedIs supportedIs supportedIs supportedIs supported

Attributes and values

An attribute is a piece of additional information about a tag. While tags denote the type of objects they mark or create, attributes set the parameters of these objects. These parameters can include anything from the types of possible interactions to its visual style to its actual contents.

Values indicate how a certain attribute is actually implemented, if there is a number of ways it can happen.

What attributes are actually allowed in a certain tag depends on the tag itself. Much like possible attributes depend on a tag, possible values depend on an attribute.

The <script> tag supports the following attributes (with their respective values):

AttributeValueDescription
asyncasyncSpecifies that the script is executed asynchronously (only for external scripts)
charsetcharsetSpecifies the character encoding used in an external script file
deferdeferSpecifies that the script is executed when the page has finished parsing (only for external scripts)
srcURLSpecifies the URL of an external script file
typemedia_typeSpecifies the media type of the script
xml:spacepreserveSpecifies whether whitespace in code should be preserved
(Not Supported in HTML5)

Global Attributes

Global attributes are HTML tag attributes that can be used by any tag, hence the name "global". They are in contrast to unique attributes that are tag-specific.

<script> supports global attributes.

Event Attributes

Event attributes are HTML tag attributes that allow triggering actions upon specific conditions, hence the name "event". Other types of attributes, namely global and unique attributes, can also trigger actions, but the difference is that even attributes allow calling scripts, such as JavaScript functions, while most other attributes only support a certain type of action.

<script> does not support event attributes.