ch2 HTML
ch2 HTML
This figure shows the 16 basic color names that are recognized by all versions of HTML.
This figure shows a partial list of these additional color names. The extended color
name list allows you to create color schemes with greater color variation.
This figure shows the colors yellow, magenta, cyan, and white
are produced by adding the three primary colors.
Title URL
ColorMix http://www.colormix.com/
However you decide to work with color in your Web pages, it’s important to
understand how HTML handles color, if for no other reason than to be able to
interpret the HTML source code of the pages you explore on the Web.
• The <font> tag allows you to specify the color, the size,
and the font to be used for text on a Web page.
• The syntax for the <font> tag is:
<font size=“size” color=“color” face=“face”>
text </font>
– size attribute allows you to specify the font size of the text
– color attribute allows you to change the color of individual
characters or words
– face attribute specifies a particular font for a section of text
This figure shows a representation of the various font sizes for a typical browser.
to Specify Color
text will
appear in red
subtitle
appears in red
Creating Web Pages with HTML 26
Prepared by: C. Hueckstaedt
XP
Inserting a Background Image
The increased
compression cuts moderate compression: file size = 20.7 KB
minimal compression: file size = 84.3 KB
the file size to one-
tenth that of the
original. The
resulting image is
less well-defined
than the image with
low compression.
medium compression: file size = 14.2 KB heavy compression: file size = 8.6 KB
absmiddle Aligns the middle of the object with the middle of the surrounding text. The absolute middle is the midpoint between the
absolute bottom and text top of the surrounding text.
baseline Aligns the bottom of the object with the baseline of the surrounding text.
bottom Aligns the bottom of the object with the bottom of the surrounding text. The bottom is equal to the baseline minus the
standard height of a descender in the text.
left Aligns the object to the left of the surrounding text. All preceding and subsequent text flows to the right of the object.
middle Aligns the middle of the object with the surrounding text.
right Aligns the object to the right of the surrounding text. All subsequent text flows to the left of the object.
texttop Aligns the top of the object with the absolute top of the surrounding text. The absolute top is the baseline plus the height of
the largest ascender in the text.
top Aligns the top of the object with the top of the text. The top of the text is the baseline plus the standard height of an
ascender in the text.
This figure shows the effect of each alignment options on text surrounding the image.
• Another set of attributes for the <img> tag are the height and
width attributes.
• Height and width attributes instruct the browser to display an
image at a specific size.
• Changing the size of the image within the <img> tag does not
affect the file size, it makes the image look smaller improving
the performance of the Web page.
• The syntax for setting the height and width attributes is: <img
src=“URL” height=“value” width=“value”>
– value is the height and width of the image either in pixels or as a
percentage of the page’s height and width
Creating Web Pages with HTML 41
Prepared by: C. Hueckstaedt
XP
Using the alt Attribute
This figure is an
example of a park
map that visitors can
easily find their way
to all of the different
attractions by
clicking on the
image.
rides.htm water.htm
Creating Web Pages with HTML 45
Prepared by: C. Hueckstaedt
XP
Server-Side Image Maps
• Create the <map> tag that defines the different hotspots on the image
as follows:
<map name=“mapname”>
<area shape=“shape” coords=“coordinates”
href=“URL” target=“window”>
. . .
</map>
– mapname is the name you give the image map
– shape is the type of hotspot (rectangle, circle, or polygon)
– coordinates are the locations of points that define the shape
– URL is the location of the linked page
– window is the name of a secondary browser window
Title URL
LiveImage http://www.mediatec.com/
MapEdit http://www.boutell.com/mapedit/
• Within the <map> tag, enter the code for the type of
hotspot(s) and the coordinates.
• The syntax for a rectangular hotspot is:
<area shape=“rect” coords=“x_left,
y_upper, x_right, y_lower” href=“URL”
target=“window”>
– x_left, y_upper are the coordinates of the upper-left
corner of the rectangle
– x_right, y_lower are the coordinates of the lower-right
corner
(230 , 225)
(370 , 225)
image map
name
polygonal
hotspot
circular
hotspot
rectangular
hotspot
name of
image to use
properties
of image
map
Creating Web Pages with HTML 62
Prepared by: C. Hueckstaedt
XP
Image Map and Hotspots Continued
pointer changes
to a hand as it
passes over a hot
spot
two rows
two columns
beginning of the
table structure
table cells
Text in cells
formatted with the
<th> tag is bold and
centered above each
table column.
table headings
table headings
appear bold
and centered
over their
columns
caption will be
centered above
the table
This figure shows the effect on a table’s border when the border size is varied.
• The align attribute is similar to the align attribute used with the
<img> tag.
This figure
shows a right-
aligned table.
right-aligned column
This cell
spans two this cell
columns and spans three
two rows columns
This cell
spans three
rows
four table
cells in the
first row
only three table
cells are
required for the
second and third
rows
HTML code
resulting table
this cell
spans two
columns
these cells
span three
rows
spanning cells
This figure shows that Internet Explorer applies the same color to all parts of the border,
thus removing the 3-D effect; Netscape does not.
This figure shows an example of the use of the bordercolor and bordercolorlight
attributes to create a 3-D colored border in Internet Explorer.
Netscape does not support these attributes.
Internet Explorer