Computer >> Computer tutorials >  >> Programming >> Javascript

How to include inline JavaScript inside an HTML page?


JavaScript is used in HTML using the <script>…</script> or using External JavaScript file. Well, there’s another way through which you can include inline JavaScript inside an HTML page.

Generally, the HTML event attributes calls functions specified elsewhere in script tags. But, you can also add the JavaScript code directly to the onClick event tags.

How to include inline JavaScript inside an HTML page?

Note: Adding inline JavaScript isn’t considered a good practice according to coding standards and shouldn’t be followed.

<p>
   <a href="#" onClick="alert('Hello World');">
      Click
   </a>
</p>