HTML and CSS Reference
the random number by taking the size of the array (randomImage.length) and subtracting
1 from that size. This subtraction is necessary because an array's first element is identified
as element zero. Line 26 generates the random number using the Math.ceil() method and
Math.random() methods. The Math.random() method generates a number between 0 and 1.
The result is multiplied by the array size, which in this case is seven, minus one to give us six
The multiplication by the array size provides a number between 1 and 7, and the
Math.ceil() method will round the value to the next integer, which is assigned to the
variable randomnumber. The randomnumber value is used in line 27 to assign an array
element to the image placeholder. Line 28 closes the function.
To Enter a Random Number Generator User-Defined Function
The following step enters the user-defined function, rndimage(), to randomly assign an image to the image
null entry because
zero element is
Click line 22 and press
the e n t e r key once.
On line 23, enter
shown in Table 11-8
to create the user-
defined function to
randomly assign an
image to the image
placeholder, as shown
in Figure 11-10.
line 23 fills array
of images for
random number used to
pick image from array and
display on Web page
e n t e r
To Enter Code to Show Copyright Information and Date Last Modified
As shown in Figure 11-1a on page HTML 509, the Hickory Oaks Forest Preserve Home page displays
copyright information, the date the file was last modified, and the URL at the bottom of the Web page. To show just
First, however, a <div> or <footer> container tag with an id attribute must be inserted in the HTML code where the
message is to display. Table 11-9 shows the HTML code for the <footer> tag with the id attribute and class attribute
for formatting the copyright display. By adding a class attribute, a style sheet entry can format the text for this
container, eliminating the need for an inline style.
Table 11-9 Code for <footer> Tag with the id and class Attributes
<footer id=”displayCopyRight” class=”footer_format”>
information and date the Web page was last modified.