The "script" Element

Related:

Additional links:

Use the "script" element to include scripts and data blocks in the document. Use the "src" attribute to specify a script in an external file.

Attributes for "script"
TypeAttribute List
'Standard' Attributes"amp-access", "amp-access-hide", "charset", "custom-element", "custom-template", "defer", "fallback", "integrity", "placeholder", "src", and "type"
New HTML5 Attributes"async" and "crossorigin"
New HTML 5.1 Attributes"nonce"
Obsolete Attributes"language", "for", and "event"

Syntax Notes for "script"

  • The end tag is required.
  • In HTML5+, type="text/javascript" may be left out because it's the default. However, HTML 4.01 requires the "type" attribute and CSE HTML Validator will warn you about this if the "type" attribute is omitted in a pre-HTML5 document.

Notes

  • It's generally best to use the "src" attribute to place scripts in external files.

Recommended Links

Search Engine Optimization (SEO)

  • Avoid using client-side scripting to insert tags and content into web pages. Don't use client-side scripting to link to other documents. Search Engines don't run client-side scripting. It's also a bad idea because it should not be assumed that scripting is available (and turned on) in the user's browser.

Search Engine Links (for more information)

Help us improve this page: Suggest a link or noteReport a problem