HTML JavaScript
In the context of web development, "HTML" and "JavaScript" are two distinct but closely related technologies that are often used together to create dynamic and interactive web pages.
The HTML <script> Tag
The HTML <script>
tag is used to define a client-side script (JavaScript).
The <script>
element either contains script 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.
To select an HTML element, JavaScript most often uses the document.getElementById()
method.
This JavaScript example writes "Hello JavaScript!" into an HTML element with id="demo":
A Taste of JavaScript
Here are some examples of what JavaScript can do:
The HTML <noscript> Tag
The <noscript>
tag in HTML is used to provide alternative content that should be displayed when a browser does not support or has disabled JavaScript. The content within the <noscript>
. tag is intended for situations where JavaScript is either not available or disabled in the user's browser.
Example
<p id="demo"> <script> document.getElementById("demo").innerHTML = "Hello JavaScript!"; </script> <noscript>Sorry, your browser does not support JavaScript!</noscript> <p>A browser without support for JavaScript will show the text written inside the noscript element.</p>You can click on above box to edit the code and run again.
Output
A browser without support for JavaScript will show the text written inside the noscript element.