HTML - Scripts




HTML Scripts

With HTML scripts, you can create dynamic web pages, make image rollovers for really cool menu effects, or even validate the data on your HTML forms before users submit their information.

HTML Scripts gives us way to embed or include client side script into the HTML Document. HTML script (<script>…</script>) tag is used to include a block of client side script or to call it from external source.

Internal Script

You can define your custom block or function of client side scripting language inside a HTML Document itself.

Example

<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Text</h2>
<p>In this paragraph writes "Hello JavaScript!""</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script> 
</body>
</html>

Result

JavaScript Text

In this paragraph writes "Hello JavaScript!"

External Script

If you have ready to use client side script library or custom script that you want to reuse then you can call into the HTML Document.

Example

<script src="custom.js" type="text/javascript" />