HTML and CSS Reference
The Meaning of this
You might be a bit puzzled by the use of this as a variable name in an event han-
dler. Here, this is shorthand for the current object. When you're using an event han-
dler in a tag, this refers to the object represented by that tag. In the previous
example, it refers to the link that the user clicked on. The advantage of using this
is that it places the event in a useful context. I could use the same attribute value
with any link and the code would still work as expected. It's particularly useful when
you're using functions as event handlers and you want to make them easy to reuse.
You'll see a lot more of this in the next lesson.
At one time, using event-handler attributes to bind functions to events was the most com-
mon approach, but these days, it's more common to bind events to elements in other
using the event-handler attributes can override event bindings that are applied from
ments without changing your markup at all.
The list of statements, functions, and options included in this lesson represents
For this reason, I cannot overemphasize the importance of the online documentation
page without having to deal with the many difficulties associated with programming in
high-level languages such as Java or C++.
scripts into an HTML document. In addition, you explored the basic structure of the
With this basic knowledge behind you, in the next lesson, you'll explore some real-world