Learn HTML

"Are you looking to learn HTML from scratch? Look no further! Our HTML course is designed for both beginners and advanced learners who want to master the fundamental concepts of HTML. Our comprehensive course covers everything from the basic concepts of HTML, including tags, attributes, and elements, to the more advanced concepts such as multimedia, responsive design, and accessibility."

HTML JavaScript

JavaScript is a programming language that can be used to add dynamic behavior to HTML pages. By using JavaScript, you can create interactive elements, perform calculations, manipulate the document object model (DOM), and communicate with servers to retrieve and send data.

 

include JavaScript in your HTML page

To include JavaScript in your HTML page, you can use the <script> tag, which allows you to embed JavaScript code directly into your HTML document. Here is an example:


<!DOCTYPE html>
<html>
 <head>
   <title>My JavaScript Page</title>
   <script>
     function myFunction() {
       document.getElementById("demo").innerHTML = "Hello JavaScript!";
     }
   </script>
 </head>
 <body>
   <h1>JavaScript Example</h1>
   <p id="demo">Click the button to change the text.</p>
   <button onclick="myFunction()">Click me</button>
 </body>
</html>


In this example, we have included a script block in the HTML document that defines a function called myFunction(). This function uses JavaScript to manipulate the contents of the demo paragraph element, changing its innerHTML to "Hello JavaScript!" when the user clicks the button.

 

JavaScript included in as external file

JavaScript code can also be included in an external file and linked to the HTML document using the src attribute of the <script> tag. For example:


<!DOCTYPE html>
<html>
 <head>
   <title>My JavaScript Page</title>
   <script src="myscript.js"></script>
 </head>
 <body>
   <h1>JavaScript Example</h1>
   <p id="demo">Click the button to change the text.</p>
   <button onclick="myFunction()">Click me</button>
 </body>
</html>


In this example, we have linked an external JavaScript file called myscript.js to the HTML document using the src attribute. The contents of the myscript.js file might look something like this:


function myFunction() {
 document.getElementById("demo").innerHTML = "Hello JavaScript!";
}


By using external JavaScript files, you can keep your code organized and easier to maintain, and you can reuse the same code across multiple pages on your website.