HomeReferencesHTML Tags

HTML Tag: script

Used to define a scripting language, such as JavaScript.

HTML Dog, The Book HTML Dog book cover

HTML Dog is hosted by Titan Internet

Required Attributes

  • type is used to specify what type of scripting language is used. This takes the form of a MIME type such as text/javascript.

Optional Attributes

  • src can be used to specify an external source of a script file.
  • charset can be used to specify the character set of the element.
  • defer can be used to specify that the script does not generate any document content so that the browser doesn't have to worry about it while the page loads. It must be used in the format defer="defer".

Example


<script type="text/javascript" src="somescript.js"></script>
<script type="text/javascript">
	function koala() {
		alert('KOALA! KOALA!');
	}
</script>