Where JavaScript Goes on Your Web Pages

Now let's get down to some JavaScript basics. Figure 1-4 shows you the thinnest possible skeleton of an HTML page with JavaScript.

An HTML page with JavaScript

Figure 1-4. An HTML page with JavaScript

In Figure 1-4, you can see the JavaScript between the <script type = "text/javascript"> and </script> tags in ❶ and ❷.

Note that you can also start JavaScript with this <script> tag:

<script language = "JavaScript">

Although this will work in all browsers, it's better to stick to the official format:

<script type = "text/javascript">

If you feel like being extra clear, you can explicitly state which version of JavaScript your script will support. ...

Get The Book of JavaScript, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.