How to define a client-side script in HTML5 ? Last Updated : 22 Mar, 2021 Comments Improve Suggest changes Like Article Like Report To define a client-side script in HTML5, we can do <script> tag or adding external script file by src attribute to the HTML file. <script> tag contains the JavaScript to be added for the client-side scripting. Syntax: <script> // JavaScript goes here console.log('GeeksforGeeks'); </script> Below are the examples for the above approach: Example 1: Here script is added using <script> tag. HTML <!DOCTYPE html> <html> <body> <h1>Welcome To GFG</h1> <p id="id1"> Default code has been loaded into the Editor. </p> <script> document.getElementById("id1").innerHTML= "Welcome to GeeksForGeeks" </script> </body> </html> Output: Example 2: Here, external JavaScript is used for scripting. index.html <!DOCTYPE html> <html> <body> <h2>External JavaScript</h2> <p id="id1"> This is before you click the button </p> <button type="button" onclick="clickMe()"> Click Me </button> <script src="main.js"></script> </body> </html> main.js function clickMe() { document.getElementById("id1").innerHTML = "This is after you click the button"; } Output: Comment More infoAdvertise with us Next Article How to define a client-side script in HTML5 ? S sahithya3098 Follow Improve Article Tags : Web Technologies HTML HTML5 HTML-Tags HTML-Questions +1 More Similar Reads How to Add JavaScript in HTML Document? To add JavaScript in HTML document, several methods can be used. These methods include embedding JavaScript directly within the HTML file or linking an external JavaScript file.Inline JavaScriptYou can write JavaScript code directly inside the HTML element using the onclick, onmouseover, or other ev 3 min read How to define the URL of an external script file in HTML5 ? In this article, we will learn how to define the URL of an external script file inside HTML. This may be needed when a large script code is needed to be included, and it may create confusion if all the code is written in a single file. Also, there may be a requirement for the same script to execute 1 min read How to call JavaScript function in HTML ? In HTML, you can easily call JavaScript functions using event attributes like onclick and onload. Just reference the function name within these attributes to trigger it. You can also call functions directly within script blocks using standard JavaScript syntax. Let's create an HTML structure with so 2 min read How to Handle JavaScript Events in HTML ? An Event is an action or occurrence recognized by the software. It can be triggered by the user or the system. Mostly Events are used on buttons, hyperlinks, hovers, page loading, etc. All this stuff gets into action(processed) with the help of event handlers. In this article, you will learn about d 3 min read How to execute a script asynchronously in HTML5 ? In this article, we will learn how to execute a script asynchronously on a webpage. This can be used in situations where loading the content is important as heavy scripts can cause the page to wait for it to load thereby making the page appear incomplete. Asynchronously loading would solve this issu 3 min read Like