Javascript — Adding JavaScript to HTML
JavaScript can be added to your HTML page in two ways:
- Inside a
<script>
tag in the HTML file. - Linked as an external file using
src
.
<!-- Inline script -->
<script>
console.log(\"Hello world\");
</script>
<!-- External script -->
<script src=\"script.js\"></script>