JavascriptAdding JavaScript to HTML

JavaScript can be added to your HTML page in two ways:

  1. Inside a <script> tag in the HTML file.
  2. Linked as an external file using src.
<!-- Inline script -->
<script>
  console.log(\"Hello world\");
</script>

<!-- External script -->
<script src=\"script.js\"></script>