HTML JavaScript
HTML Tutorial
HTML JavaScript
CompletedJavaScript are useful in making HTML pages to be more interactive and dynamic.
The HTML Tag
CompletedThe <script> tag is useful in defining a client-side script (JavaScript).
The <script> element is capable of containing scripting statements, or it refers or points to an external script file by using the src attribute.
Some of the common uses for JavaScript are image manipulation, form validation, and dynamic changes of content.
This JavaScript example explains how to write "Hello JavaScript!" into an HTML element with id="demo":
<script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>
Try it YourselfA Taste of JavaScript
CompletedBelow are few examples to show what JavaScript can do:
JavaScript has the power to change HTML content
document.getElementById("demo").innerHTML = "Hello JavaScript!";
JavaScript is capable of changing HTML styles
Example
document.getElementById("demo").style.fontSize = "25px";
document.getElementById("demo").style.color = "red";
JavaScript is capable of changing HTML attributes
Example
document.getElementById("image").src = "picture.gif";
The HTML Tag
CompletedThe <noscript> tag is used for providing an alternate content for users who had disabled scripts in their browser or having a browser which does not support client-side scripts:
Example
<script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>
<noscript>Sorry, your browser does not support JavaScript!</noscript>
Try it Yourself
HTML Script Tags
Completed| Tag | Description |
|---|---|
| <script> | It is used to define a client-side script |
| <noscript> | It is used to define an alternate content for users who do not have support client-side scripts in their browsers |
