HTML and CSS Reference
In-Depth Information
Figure 2.3: A web page that responds to a mouse click
First, note that another rule has been added to the CSS style container in
the document head section for the h1 element:
color: darkblue;
his CSS rule renders any of the page's level-one headings in a dark blue
color. Also, a horizontal rule has been added below the paragraph using the
self-closing element <hr/> . You can't miss it. It is next to the comment
<!-- horizontal rule --> . Comments are an important part of any web page
and should be used frequently to help other people understand what the code
is supposed to do. Browsers ignore comments, which do not afect the display
of the page in any way. Robots are free to ignore comments or to make of them
what they will.
At the end of Example 2.3, a script container has been added ater the clos-
ing body tag, following a comment describing what the JavaScript is supposed
to do:
<script type="text/javascript">
document.body.onclick = function () { = 'red';
he script consists of a single statement that adds a behavior to the docu-
ment's body element. When the reader clicks the document, the text turns red.
Try this out in your favorite browser, and you will notice some behavior that
you might not have expected:
. First, the mouse must be clicked on or above the horizontal rule that
Search WWH ::

Custom Search