HOME C C++ PYTHON JAVA HTML CSS JAVASCRIPT BOOTSTRAP JQUERY REACT PHP SQL AJAX JSON DATA SCIENCE AI

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 <tscript> tag in HTML is used to embed or reference JavaScript code within an HTML document. This tag allows developers to include client-side JavaScript directly within the HTML file or link to an external JavaScript file. The <script> tag is essential for adding interactivity, dynamic behavior, and functionality to web pages.

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":

Example

              
<script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>
You can click on above box to edit the code and run again.

Output

A Taste of JavaScript

Here are some examples of what JavaScript can do:

Example


document.getElementById("demo").innerHTML = "Hello JavaScript!";
You can click on above box to edit the code and run again.

Output

Example


document.getElementById("demo").style.fontSize = "35px";
document.getElementById("demo").style.color = "red";
document.getElementById("demo").style.backgroundColor = "yellow";

You can click on above box to edit the code and run again.

Output

Example

document.getElementById("image").innerHTML = ""picture.gif"";

You can click on above box to edit the code and run again.

Output

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

             
<script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>
<noscript>Sorry, your browser does not support JavaScript!</noscript>
You can click on above box to edit the code and run again.
You can click on above box to edit the code and run again.

Output