The HTML file

This is the HTML file:

As you can see, we have given an id to the textarea. Also, we have given an id to an empty span. This is where we will display our wordcount using JavaScript.

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Word counter </title>
  </head>
  <body>
    <h3> Word counter </h3>
    <textarea id="myWordsToCount" rows="5" cols="60" ></textarea><br>
    The wordcount is: <span id="wordcount"></span><br>
    <script type="text/javascript" src="js/countsTheWords.js"></script>
  </body>
</html>

Exercise

  1. Open your editor, create a new file and save it as exersice07.3.01.html in the folder "yourNameWEB2JS".
  2. Copy the above code and paste it into the new file.
  3. Modify and save the file.