HTML 5 and CSS 3 – Illustrated 2nd Ed. Instructor’s Manual: Unit L Page 5 of 10
• Point out that every JavaScript statement ends with a semicolon.
• Explain that statements are created in an external JavaScript file, which is a text file with a name
that ends with the extension .js. Point out that you use the script element to reference these files
within an HTML document, as students have already seen.
TEACHER TIP
In the interest of simplifying the subject matter, this book omits mention of embedded JavaScript code,
in which the code is placed within the HTML document between the opening and closing tags of a
script element. If you choose to cover this topic, be sure to point out that a best practice in modern
web development is to keep HTML, CSS, and JavaScript code in separate files, so creating embedded
JavaScript is no longer common.
FIGURES: M-4, M-5, M-6, M-7
BOXES:
1. Trouble: Be sure to enter the selector as .feedback-from rather than .feedback-form.
2. Trouble: If reloading does not remove the changes, open contact.html in a new tab.
3. Trouble: If the text shown in Figure M-7 is not displayed in your browser, return to script.js in your
editor, compare your statements with the code shown in Steps 4 and 5, and ensure that both lines end
with a semicolon.
4. Debugging JavaScript Code
As with HTML and CSS code, sometimes the JavaScript code that you write doesn’t produce the results
you expect. In such cases, your first step should be to open the browser console, check for any error
messages, and then examine the referenced location in your code for possible errors. In cases when
CLASSROOM ACTIVITIES
1. Classroom Discussion: What applications can you think of for assigning a new value to a property on
a web page using JavaScript?
2. Quick Quiz:
b. In a JavaScript statement, the code on the __________ side of the equal sign accesses the
c. T/F To reference an external script file in an HTML document, you use the script