Category: HTML & XHTML: The Definitive Guide, 4th Edition


Chapter 17. Tips, Tricks, and Hacks


17.1.2. Boilerplate Documents
<html>
<head>
<title>Required; replace this title with your own</title>
</head>
<body>
<h3>Reiterate the title here</h3>
…Insert your document’s contents here…
<address>Include your name and contact information
usually at the end of the document
</address>
</body>
</html>

1712

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
” http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<title>Every XHTML document needs a title</title>
</head>
<body>
<h3>Reiterate the title here</h3>
…Insert your document’s contents here…
<address>Include your name and contact information
usually at the end of the document
</address>
</body>
</html>

17.3. Custom Bullets
<html>
<body>
<dl>
<dt><dd><img src=”checkmark.gif”> Pickled Kumquats
<dt><dd><img src=”checkmark.gif”> ‘Quats and ‘Kraut
<dt><dd><img src=”checkmark.gif”> ‘Quatshakes
<dt><dd><img src=”checkmark.gif”> Liver with Fried ‘Quats
</dl>
</body>
</html>

173

<html>
<body>
<style>
ul.checks li {list-style-image: url(“pics/checkmark.gif”)}
</style>
…later in the document
<ul class=”checks”>
<li> Pickled Kumquats </li>
<li> ‘Quats and ‘Kraut </li>
<li> ‘Quatshakes </li>
<li> Liver with Fried ‘Quats </li>
</ul>
</html>

1732

17.4.1.1. Basic multicolumn layout
<html>
<body>
<table border=0 cellspacing=7>
<tr>
<td>The one thing the browsers won’t do is automatically balance the text in the columns, resulting in adjacent columns of approximately the same length. You’ll have to experiment with your document, manually shifting text from one column to another until you achieve a nicely balanced page.

Keep in mind, though, that users may resize their display windows and the columns’ contents will shift accordingly. So don’t spend a lot of time getting the last sentences of each column to line up exactly; they’re bound to be skewed in other browser window widths.

Of course, you can easily convert the example layout to three or more columns by dividing the text among more cells in the table. But keep in mind that pages with more than three columns may prove difficult to read on small displays where the actual column width might be quite small.
<td><br>
<td>One very common and popular page-layout element missing from the either HTML or XHTML standard is multiple columns of text. Although Netscape version 4 (and earlier) supports the <multicol> extension, for a more universal solution, place your document content inside a table of one row with two or more columns.
</table>
</body>
</html>

17411

17.4.1.2. Straddle heads
<html>
<body>
<table border=0 cellspacing=7>
<tr>
<th colspan=5><h2>The History of the Kumquat</h2>
<tr valign=top>
<td rowspan=2>Copy for column 1…(The one thing the browsers won’t do is automatically balance the text in the columns, resulting in adjacent columns of approximately the same length. You’ll have to experiment with your document, manually shifting text from one column to another until you achieve a nicely balanced page. )
<td rowspan=2 width=24><br>
<td>Copy for column 2…(Keep in mind, though, that users may resize their display windows and the columns’ contents will shift accordingly. So don’t spend a lot of time getting the last sentences of each column to line up exactly; they’re bound to be skewed in other browser window widths. )
<td width=24><br>
<td>Copy for column 3…(Of course, you can easily convert the example layout to three or more columns by dividing the text among more cells in the table. But keep in mind that pages with more than three columns may prove difficult to read on small displays where the actual column width might be quite small. )
<tr>
<td colspan=3 align=center><img src=”pics/fruit.gif”>
<p>
<i>The Noble Fruit</i>
</table>
</body>
</html>

17412

17.4.2. Side Heads
<html>
<body>
<table>
<tr>
<th width=”20%” align=”right”>
<h3>Section 1</h3></th>
<td></td>
<td>
Copy for section 1 goes on and on a bit
so that it will take up more than one line in the
table cell window… </td>
</tr>
<tr>
<th align=”right”>
<h3>Section 2</h3></th>
<td></td>
<td>
Copy for section 2 goes on and on a bit
so that it will take up more than one line in the
table cell window…</td>
</tr>
</table>
</body>
</html>

1742

17.4.2.1. When tables aren’t implemented
<html>
<body>
<h3>Section 1</h3>
Copy for section 1 goes on and on a bit
so that it will take up more than one line in the
table cell window…
<h3>Section 2</h3>
Copy for section 2 goes on and on a bit
so that it will take up more than one line in the
table cell window…
</table>
</body>
</html>

17421

17.4.3.1. Basic form layout
<html>
<body>
<form method=post action=”http:/cgi-bin/process”>
<table>
<tr>
<th align=right>Name:
<td><input type=text size=32>
<tr>
<th align=right>Address:
<td><input type=text size=32>
<tr>
<th align=right>Phone:
<td><input type=text size=12>
<tr>
<td colspan=2 align=center>
<input type=submit value=”Register”>
</table>
</form>
</body>
</html>

17431

17.4.3.2. Building forms with nested tables
<html>
<body>
<form method=post action=”http:/cgi-bin/process”>
<table>
<tr>
<th align=right>Name:
<td><input type=text size=32>
<tr>
<th align=right>Address:
<td><input type=text size=32>
<tr>
<th align=right>Phone:
<td><input type=text size=12>
<tr>
<td colspan=2 align=center>
<input type=submit value=”Register”>
<tr>
<th align=right valign=top>Preferences:
<td>
<table>
<tr>
<td><input type=checkbox name=pref>Lemons
<td><input type=checkbox name=pref>Limes
<tr>
<td><input type=checkbox name=pref>Oranges
<td><input type=checkbox name=pref>Kumquats
</table>
</form>
</body>
</html>

17432

17.4.4. Embedded Guides
<html>
<body>
The role of the kumquats in earthly and cosmic affairs has been well documented.
Nearly from the moment that humankind began recording history — even as
oral tradition — historians have reported the extraordinary and
omnipresent influences of kumquats.</p>
<p>
<table align=”right”>
<tr>
<td><a href=”#arts”><img src=”pics/d_arrow.gif” border=”0″></a></td>
<td><a href=”#arts”><h6>Kumquat influence<br/>in the Arts</h6></a></td>
</tr>
</table>
For instance, early in the history of man, the kumquat played a vital role in the
formation of religious beliefs.  Central to annual harvest celebrations was the day
upon which kumquats ripened.  Likened to the sun (<em>sol</em>), the golden fruit
was taken (<em>stisus</em>) from the trees on the day the sun stood highest in the
sky.  We carry this day forward even today, as our summer <em>solstice</em>.

</p>
</body>
</html>

1744

17.6.2. Overriding Others’ Targets
<html>
<head>
<title>I need a window of my own</title>
<script language=”JavaScript”>
<!–
if (self != window.top)
window.open(“http://www.kumquats.com/index2.html”);
else
self.location.href = “http://www.kumquats.com/index2.html”;
//–>
</script>
</head>
<body>
Your browser apparently doesn’t support JavaScript. Please
<a href=”http://www.kumquats.com/index2.html”> hyperlink to our site manually.</a>
</body>
</html>

1762

Chapter 16. XHTML
16.2.3. A Minimal XHTML Document
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<title>Every document must have a title</title>
</head>
<body>
…your content goes here…
</body>
</html>

1623

Chapter 15. XML
15.7.2. Using the Address DTD
<html>
<body>
<address type=”home”>
<name>
<first>Chuck</first>
<last>Musciano</last>
</name>
<street>123 Kumquat Way</street>
<city>Cary</city>
<state>NC</state>
<zip length=”10″>27513-1234</zip>
</address>
</body>
</html>

1572

Chapter 13. Dynamic Documents
13.2.2.1. Refreshing the same document
<html>
<head>
<meta http-equiv=”Refresh” content=”15″>
<title>Kumquat Market Prices</title>
</head>
<body>
<h3> Kumquat Market Prices</h3>
Kumquats are currently trading at $1.96 per pound.
</body>
</html>

132211

Chapter 14. Netscape Layout Extensions
14.1.1.1. Creating horizontal space
<html>
<body>
<spacer type=horizontal size=50>
The effects of cooler weather on the kumquat’s ripening process
vary based upon the temperature.  Temperatures above 28&deg;
sweeten the fruit, while four or more hours below 28&deg; will
damage the tree.
</body>
</body>
</html>

14111

14.1.1.2. Creating vertical space
<html>
<body>
<h1 align=right>Temperature Effects</h1>
<spacer type=vertical size=50>
The effects of cooler weather on the kumquat’s ripening process
vary based upon the temperature.  Temperatures above 28&deg;
sweeten the fruit, while four or more hours below 28&deg; will
damage the tree.
</body>
</body>
</html>

14112

14.1.1.3. Creating blocks of space
<html>
<body>
<center>
North
<br>
West
<spacer type=block width=50 height=50 align=absmiddle>
East
<br>
South
</center>
</body>
</html>

14113

14.2.1.1. The cols attribute
<html>
<body>
<h1 align=right>Temperature Effects</h1>
<multicol cols=3>
The effects of cooler weather on the kumquat’s ripening process
vary based upon the temperature.  Temperatures above 28&deg;
sweeten the fruit, while four or more hours below 28&deg; will
damage the tree.  The savvy quat farmer will carefully monitor
the temperature, especially in the predawn hours when the
mercury dips to its lowest point.  Smudge pots and grove heaters
may be required to keep the trees warm; many growers will spray
the trees with water to create an insulating layer of ice over
the fruit and leaves.
<p>
If a disastrous frost is predicted, below 20&deg;, the only
recourse may be to harvest the fruit early to save it from an
assured disaster.  Kumquats may subsequently be ripened using
any of the popular methane and cyanoacrylate injection systems
used for other citrus fruits.  Used correctly, these systems will
produce fruit whose taste is indistinguishable from tree-ripened
kumquats.
</multicol><h1 align=right>Temperature Effects</h1>
<multicol cols=3>
The effects of cooler weather on the kumquat’s ripening process
vary based upon the temperature.  Temperatures above 28&deg;
sweeten the fruit, while four or more hours below 28&deg; will
damage the tree.  The savvy quat farmer will carefully monitor
the temperature, especially in the predawn hours when the
mercury dips to its lowest point.  Smudge pots and grove heaters
may be required to keep the trees warm; many growers will spray
the trees with water to create an insulating layer of ice over
the fruit and leaves.
<p>
If a disastrous frost is predicted, below 20&deg;, the only
recourse may be to harvest the fruit early to save it from an
assured disaster.  Kumquats may subsequently be ripened using
any of the popular methane and cyanoacrylate injection systems
used for other citrus fruits.  Used correctly, these systems will
produce fruit whose taste is indistinguishable from tree-ripened
kumquats.
</multicol><h1 align=right>Temperature Effects</h1>
<multicol cols=3>
The effects of cooler weather on the kumquat’s ripening process
vary based upon the temperature.  Temperatures above 28&deg;
sweeten the fruit, while four or more hours below 28&deg; will
damage the tree.  The savvy quat farmer will carefully monitor
the temperature, especially in the predawn hours when the
mercury dips to its lowest point.  Smudge pots and grove heaters
may be required to keep the trees warm; many growers will spray
the trees with water to create an insulating layer of ice over
the fruit and leaves.
<p>
If a disastrous frost is predicted, below 20&deg;, the only
recourse may be to harvest the fruit early to save it from an
assured disaster.  Kumquats may subsequently be ripened using
any of the popular methane and cyanoacrylate injection systems
used for other citrus fruits.  Used correctly, these systems will
produce fruit whose taste is indistinguishable from tree-ripened
kumquats.
</multicol>
</body>
</html>

142111

14.2.1.2. The gutter attribute
<html>
<body>
<h1 align=right>Temperature Effects</h1>
<multicol cols=3 gutter=50>
The effects of cooler weather on the kumquat’s ripening process
vary based upon the temperature.  Temperatures above 28&deg;
sweeten the fruit, while four or more hours below 28&deg; will
damage the tree.  The savvy quat farmer will carefully monitor
the temperature, especially in the predawn hours when the
mercury dips to its lowest point.  Smudge pots and grove heaters
may be required to keep the trees warm; many growers will spray
the trees with water to create an insulating layer of ice over
the fruit and leaves.
<p>
If a disastrous frost is predicted, below 20&deg;, the only
recourse may be to harvest the fruit early to save it from an
assured disaster.  Kumquats may subsequently be ripened using
any of the popular methane and cyanoacrylate injection systems
used for other citrus fruits.  Used correctly, these systems will
produce fruit whose taste is indistinguishable from tree-ripened
kumquats.
</multicol>
</body>
</html>

14212

14.2.1.3. The width attribute
<html>
<body>
<h1 align=right>Temperature Effects</h1>
<multicol cols=3 gutter=10 width=500 width=”75%”>
The effects of cooler weather on the kumquat’s ripening process
vary based upon the temperature.  Temperatures above 28&deg;
sweeten the fruit, while four or more hours below 28&deg; will
damage the tree.  The savvy quat farmer will carefully monitor
the temperature, especially in the predawn hours when the
mercury dips to its lowest point.  Smudge pots and grove heaters
may be required to keep the trees warm; many growers will spray
the trees with water to create an insulating layer of ice over
the fruit and leaves.
<p>
If a disastrous frost is predicted, below 20&deg;, the only
recourse may be to harvest the fruit early to save it from an
assured disaster.  Kumquats may subsequently be ripened using
any of the popular methane and cyanoacrylate injection systems
used for other citrus fruits.  Used correctly, these systems will
produce fruit whose taste is indistinguishable from tree-ripened
kumquats.
</multicol>
</body>
</html>

14213

14.3.1.2. The left and top attributes
<html>
<body>
<layer left=10 top=10>
Upper left!
</layer>
<layer left=50 top=50>
Middle!
</layer>
<layer left=90 top=90>
Lower right!
</layer>
</body>
</html>

14312

<html>
<body>
<layer>
<layer left=2 top=2>
<h1><font color=gray>Introduction to Kumquat Lore</font></h1>
</layer>
<layer left=0 top=0>
<h1>Introduction to Kumquat Lore</h1>
</layer>
</layer>
<h1>&nbsp;</h1>
Early in the history of man, the kumquat played a vital role in the
formation of religious beliefs. Central to annual harvest celebrations
was the day upon which kumquats ripened. Likened to the sun (<i>
sol</i>), the golden fruit was taken (<i>stisus</i>) from the trees on
the day the sun stood highest in the sky.  We carry this day forward
even today, as our summer <i>solstice</i>.
t!
</body>
</html>

143121

14.3.1.3. The above, below, and z-index attributes

<html>
<body>
<layer>
<layer name=text left=0 top=0>
<h1>Introduction to Kumquat Lore</h1>
</layer>
<layer name=shadow above=text left=2 top=2>
<h1><font color=gray>Introduction to Kumquat Lore</font></h1>
</layer>
</layer>
<h1>&nbsp;</h1>
Early in the history of man, the kumquat played a vital role in the
formation of religious beliefs. Central to annual harvest celebrations
was the day upon which kumquats ripened. Likened to the sun (<i>
sol</i>), the golden fruit was taken (<i>stisus</i>) from the trees on
the day the sun stood highest in the sky.  We carry this day forward
even today, as our summer <i>solstice</i>.
t!
</body>
</html>

14313

<html>
<body>
<layer>
<layer left=0 top=0 z-index=2>
<h1>Introduction to Kumquat Lore</h1>
</layer>
<layer left=2 top=2 z-index=1>
<h1><font color=gray>Introduction to Kumquat Lore</font></h1>
</layer>
</layer>
<h1>&nbsp;</h1>
Early in the history of man, the kumquat played a vital role in the
formation of religious beliefs. Central to annual harvest celebrations
was the day upon which kumquats ripened. Likened to the sun (<i>
sol</i>), the golden fruit was taken (<i>stisus</i>) from the trees on
the day the sun stood highest in the sky.  We carry this day forward
even today, as our summer <i>solstice</i>.
t!
</body>
</html>

143131

<html>
<body>
<layer left=0 top=0 z-index=3>
<h1><font color=red>Introduction to Kumquat Lore</font></h1>
</layer>
<layer left=4 top=4>
<h1><font color=green>Introduction to Kumquat Lore</font></h1>
</layer>
<layer left=8 top=8 z-index=2>
<h1><font color=blue>Introduction to Kumquat Lore</font></h1>
</layer>
<h1>&nbsp;</h1>
Early in the history of man, the kumquat played a vital role in the
formation of religious beliefs. Central to annual harvest celebrations
was the day upon which kumquats ripened. Likened to the sun (<i>
sol</i>), the golden fruit was taken (<i>stisus</i>) from the trees on
the day the sun stood highest in the sky.  We carry this day forward
even today, as our summer <i>solstice</i>.
t!
</body>
</html>

143132

14.3.1.4. The background and bgcolor attributes

<html>
<body>
<layer>
<img src=”dbz_3_640.jpeg”>
<p>
<layer top=75>
<h2 align=center>And they lived happily ever after…</h2>
</layer>
</layer>
<h1>&nbsp;</h1>
Early in the history of man, the kumquat played a vital role in the
formation of religious beliefs. Central to annual harvest celebrations
was the day upon which kumquats ripened. Likened to the sun (<i>
sol</i>), the golden fruit was taken (<i>stisus</i>) from the trees on
the day the sun stood highest in the sky.  We carry this day forward
even today, as our summer <i>solstice</i>.
t!
</body>
</html>

14314

14.3.2.1. The top and left attributes
<html>
<body>
This <ilayer top=4>word</ilayer> is shifted down, while
this <ilayer left=10>one</ilayer> is shifted over.  With a negative
value, words can be moved <ilayer top=-4>up</ilayer> and to
the <ilayer left=-10>left</ilayer>.
</body>
</html>

143211

14.3.2.2. Combining <layer> and <ilayer>
<html>
<body>
<center>
<layer name=me>I’m on top</layer><br><br>
<ilayer above=me>I’m on the bottom</ilayer>
</center>
</body>
</html>

14322

Chapter 11. Frames

11.2. Frame Tags
<html>
<head>
<title>Frames Layout</title>
</head>
<frameset rows=”60%,*” cols=”65%,20%,*”>
<frame src=”frame1.html”>
<frame src=”frame2.html”>
<frame src=”frame3.html” name=”fill_me”>
<frame scrolling=yes src=”frame4.html”>
<frame src=”frame5.html”>
<frame src=”frame6.html”>
<noframes>
Sorry, this document can be viewed only with a
frames-capable browser.
<a href = “frame1.html”>Take this link</a>
to the first HTML document in the set.
</noframes>
</frameset>
</html>

112

11.3.2. Nesting <frameset> Tags
<html>
<frameset cols=”50%,*”>
<frameset rows=”50%,*”>
<frame src=”frame1.html”>
<frame src=”frame2.html”>
</frameset>
<frameset rows =”33%,33%,*”>
<frame src=”frame3.html”>
<frame src=”frame4.html”>
<frame src=”frame5.html”>
</frameset>
</frameset>
</html>

1132

11.7.1. The target Attribute for the <a> Tag
<html>
<frameset cols=”150,*”>
<frame src=”toc.html”>
<frame src=”pref.html” id=”view_frame”>
</frameset>
</html>

Toc.html
<html>
<body>
<h3>Table of Contents</h3>
<ul>
<li><a href=”pref.html” target=”view_window”>Preface</a>
<li><a href=”chap1.html” target=”view_window”>Chapter 1</a>
<li><a href=”chap2.html” target=”view_window”>Chapter 2</a>
<li><a href=”chap3.html” target=”view_window”>Chapter 3</a>
</ul>
</body>
</html>

1171

Pref.html
<html>
<body>
The first time the user selects one of the table of
contents hypertext links, the browser will open a new window,
label it “view_window,” and display the desired document’s
contents inside it. If the user selects another link from the table of
contents and the “view_window” is still open, the browser will again
load the selected document into that window, replacing the previous document.
</body>
</html>
pref <html>
<body>
The first time the user selects one of the table of
contents hypertext links, the browser will open a new window,
label it “view_window,” and display the desired document’s
contents inside it. If the user selects another link from the table of
contents and the “view_window” is still open, the browser will again
load the selected document into that window, replacing the previous document.
</body>
</html>

toc


11.7.3. The <base> Default Target

<html>
<head>
<title>Table of Contents</title></head>
</nody>
<base target=”view_frame”>
</head>
<body>
<h3>Table of Contents</h3>
<ul>
<li><a href=”pref.html”>Preface</a></li>
<li><a href=”chap1.html”>Chapter 1</a></li>
<li><a href=”chap2.html” >Chapter 2</a></li>
<li><a href=”chap3.html”>Chapter 3</a></li>
</ul>
</body>
</body>
</html>

1173

Chapter 10. Tables


10.1.2. An Example Table
<html>
<body>
<table border cellspacing=0 cellpadding=5>
<caption align=bottom>
Kumquat versus a poked eye, by gender</caption>
<tr>
<td colspan=2 rowspan=2></td>
<th colspan=2 align=center>Preference</th>
</tr>
<tr>
<th>Eating Kumquats</th>
<th>Poke In The Eye</th>
</tr>
<tr align=center>
<th rowspan=2>Gender</th>
<th>Male</th>
<td>73%</td>
<td>27%</td>
</tr>
<tr align=center>
<th>Female</th>
<td>16%</td>
<td>84%</td>
</tr>
</table>
</body>
</html>

1012-png

10.2.3.1. The align and valign attributes
<html>
<body>
<table border=”border”>
<tr>
<th>Alignment</th>
<th>Top</th>
<th>Baseline</th>
<th>Center</th>
<th>Bottom</th>
</tr>
<tr align=”center”>
<th><h1>Baseline_  _<br />Another line</h1></th>
<td valign=”top”>AAyy</td>
<td valign=”baseline”>_AAyy_</td>
<td valign=”center”>AAyy</td>
<td valign=”bottom”>AAyy</td>
</tr>
</table>
</body>
</html>

10231-png

10.3.5. Using Table Sections
<html>
<body>
<table border cellspacing=0 cellpadding=5 rules=groups>
<caption align=bottom>Kumquat versus a poked eye, by gender</caption>
<thead>
<tr>
<td colspan=2 rowspan=2>
<th colspan=2 align=center>Preference
</tr>
<tr>
<th>Eating Kumquats
<th>Poke In The Eye
</tr>
</thead>
<tbody>
<tr align=center>
<th rowspan=2>Gender
<th>Male
<td>73%
<td>27%
</tr>
<tr align=center>
<th>Female
<td>16%
<td>84%
</tr>
</tbody>
<tfoot>
<tr>
<td colspan=4 align=center>
Note: eye pokes did not result in permanent injury
</table>
</body>
</html>

1035-png

<html>
<body>
<table border cellspacing=0 cellpadding=5 rules=groups>
<caption align=bottom>Kumquat versus a poked eye, by gender</caption>
<thead>
<tr>
<td colspan=2 rowspan=2>
<th colspan=2 align=center>Preference
<tr>
<th>Eating Kumquats
<th>Poke In The Eye
<tbody>
<tr align=center>
<th rowspan=4>Gender
<th>Males under 18
<td>94%
<td>6%
<tr align=center>
<th>Males over 18
<td>73%
<td>27%
<tr align=center>
<th>Females under 18
<td>34%
<td>66%
<tr align=center>
<th>Females over 18
<td>16%
<td>84%
<tfoot>
<tr>
<td colspan=4 align=center>
Note: eye pokes did not result in permanent injury
</table>
</body>
</html>

a

10.3.9. Using Column Groups
<html>
<body>
<table border= cellspacing=0 cellpadding=5 rules=groups>
<caption align=bottom>Kumquat versus a poked eye, by gender</caption>
<colgroup span=2>
<colgroup span=2>
<thead>
<tr>
<td colspan=2 rowspan=2>
<th colspan=2 align=center>Preference
<tr>
<th>Eating Kumquats
<th>Poke In The Eye
<tbody>
<tr align=center>
<th rowspan=4>Gender
<th>Males under 18
<td>94%
<td>6%
<tr align=center>
<th>Males over 18
<td>73%
<td>27%
<tr align=center>
<th>Females under 18
<td>34%</td>
<td>66%</td>
<tr align=center>
<th>Females over 18
<td>16%
<td>84%
<tfoot>
<tr>
<td colspan=4 align=center>
Note: eye pokes did not result in permanent injury
</table>
</body>
</html>

1039-png

Chapter 9. Forms
9.3. A Simple Form Example
<html>
<body>
<form method=POST action=”http://www.kumquat.com/demo”>
Name:
<input type=text name=name size=32 maxlength=80>
<p>
Sex:
<input type=radio name=sex value=”M”> Male
<input type=radio name=sex value=”F”> Female
<p>
Income:
<select name=income size=1>
<option>Under $25,000
<option>$25,001 to $50,000
<option>$50,001 and higher
</select>
<p>
<input type=submit>
</form>
</body>
</html>

93

9.4. Using Email to Collect Form Data
<html>
<body>
<form method=POST action=”mailto:chuckandbill@oreilly.com”
enctype=”text/plain”
onSubmit=”window.alert(‘This form is being sent by email, even
though it may not appear that anything has happened…’)”>
Name:
<input type=text name=name size=32 maxlength=80>
<p>
Sex:
<input type=radio name=sex value=”M”> Male
<input type=radio name=sex value=”F”> Female
<p>
Income:
<select name=income size=1>
<option>Under $25,000
<option>$25,001 to $50,000
<option>$50,001 and higher
</select>
<p>
<input type=submit>

</form>
</body>
</html>

94

9.5.2. Checkboxes
<html>
<body>
<form>
What pets do you own?
<p>
<input type=”checkbox” name=”pets” value=”dog” /> Dog
<br />
<input type=”checkbox” checked=”checked” name=”pets” value=”cat” /> Cat
<br />
<input type=”checkbox” name=”pets” value=”bird” /> Bird
<br />
<input type=”checkbox” name=”pets” value=”fish” /> Fish
</p>
</form>
</body>
</html>

952

9.8.1.2. The size attribute
<html>
<body>
<form>
What pets do you have?
<select name=”pets” size=”3″ multiple=”multiple”>
<option>Dog</option>
<option>Cat</option>
<option>Bird</option>
<option>Fish</option>
</select>
</form>
</body>
</html>

9812

9.8.3. The <optgroup> Tag
<html>
<body>
<form>
<select name=state>
<optgroup label=Northeast>
<option>Maine
<option>New Hampshire

</optgroup>
<optgroup label=South>
<option>Georgia
<option>Florida

</optgroup>

</select>
</form>
</body>
</html>

983

9.9.6. The disabled and readonly Attributes
<html>
<body>
<form>
Name:
<input type=text name=name size=32 maxlength=80 readonly>
<p>
Sex:
<input type=radio name=sex value=”M” disabled> Male
<input type=radio name=sex value=”F” accesskey=”f”> Female
<p>
Income:
<select name=income size=1 disabled>
<option>Under $25,000
<option>$25,001 to $50,000
<option>$50,001 and higher
</select>
<p>
<input type=submit disabled>
</form>
</body>
</html>

996-png

9.10.2.2. The <legend> tag
<html>
<body>
<form>
<fieldset>
<legend>Personal information</legend>
<label>Name:<input type=”text” /></label>
<label>Address:<input type=”text” /></label>
<label>Phone:<input type=”text” /></label>
</fieldset>
</form>
</body>
</html>

91022-png

9.11.5. Good Form, Old Chap
<html>
<body>
<form method=POST action=”http://www.kumquat.com/demo”>
<table border=0>
<tr valign=top>
<td align=right>Name:</td>
<td align=left><input type=text name=name size=32 maxlength=80>
</td>
</tr>
<tr valign=top >
<td align=right>Sex:</td>
<td align=left>
<input type=radio name=sex value=”M”> Male <br>
<input type=radio name=sex value=”F”> Female
</td>
</tr>
<tr valign=top >
<td align=right>Income:</td>
<td align=left>
<select name=income size=1>
<option>Under $25,000
<option>$25,001 to $50,000
<option>$50,001 and higher
</select>
</td>
</tr>
<tr valign=top>
<td colspan=2 align=center>
<input type=submit value=”Submit Query”>
</td>
</tr>
</table>
</form>
</body>
</html>

9115-png

Chapter 8. Cascading Style Sheets
8.1.2. Document-Level Style Sheets
<html>
<body>
<head>
<title>All True Blue</title>
<style type=”text/css”>
<!–
/* make all level-1 headers blue */
h1 {color: blue; font-style: italic}
–>
</style>
</head>
<body>
<h1>I’m so bluuuuoooo!</h1>

<h1>I am ba-loooooo, tooooo!<h1/>
</body>
</html>

812

8.1.3.1. Linked external style sheets
<html>
<body>
<head>
<title>Style linked</title>
<link rel=stylesheet type=”text/css”
href=”http://www.kumquats.com/styles/gen_styles.css”
title=”The blues”>
</head>
<body>
<h1>I’m so bluuuuoooo!</h1>

<h1> I am ba-loooooo, tooooo!<h1>
</body>
</html>

8131

8.1.3.2. Imported external style sheets
<html>
<body>
<head>
<title>Imported style sheet</title>
<style>
<!–
@import url(http://www.kumquats.com/styles/gen_styles.css);
@import “http://www.kumquats.com/styles/spec_styles.css”;
body {background: url(backgrounds/marble.gif)}
–>
</style>
</head>
</body>
</html>

8.1.5. Linked Versus Imported Style Sheets
<html>
<head>
<link rel=stylesheet href=sheet1.css type=text/css>
<link rel=stylesheet href=sheet2.css type=text/css>
<style>
<!–
@import url(sheet3.css);
@import url(sheet4.css);
–>
</style>
</head>
</html>

8.3.1. Regular Classes
<html>
<body>
<style>
<!–
p.abstract {font-style: italic;
margin-left: 0.5cm;
margin-right: 0.5cm}
p.equation {font-family: Symbol;
text-align: center}
h1, p.centered {text-align: center;
margin-left: 0.5cm;
margin-right: 0.5cm}
–>
</style>
</body>
</html>

<html>
<body>
<p class=abstract>
This is the abstract paragraph. See how the margins are indented?
</p>
<h3>The equation paragraph follows</h3>
<p class=equation>
a = b + 1
</p>
<p class=centered>
This paragraph’s text should be centered.
</p>
</body>
</html>

8311

8.3.4.3. Nesting and language pseudo-classes
<html>
<body>
div > p:first-child {font-style: italic}
<div>
<p>
I get to be in italics.
</p>
</div>
<div>
<h2> New Division</h2>
<p>
I’m in plain text because my paragraph is a second child of the division.
div:lang(it) {font-family: Roman}
</body>
</html>

8343

8.4.4.3. The background-image property
<html>
<body>
<table style=”background-image: url(backgrounds/woodgrain.gif)”>
li.marble {background-image: url(backgrounds/marble.gif)}
<h2>Here’s what’s for dinner tonight:</h2>
<ul>
<li class=”marble”>Liver with Onions</li>
<li class=”marble”>Mashed Potatoes and Gravy</li>
<li class=”marble”>Green Beans</li>
<li class=”marble”>Choice of Milk, Tea, or Coffee</li>
</ul>
<h2>And for dessert:</h2>
<ul>
<li>Creamed Quats in Milk (YUM! YUM!)</li>
</ul>
</body>
</html>

8475

Chapter 3. Anatomy of an HTML Document
3.2. Structure of an HTML Document
<html>
<head>
<title>Barebones HTML Document</title>
</head>
<body>
This illustrates, in a very <i>simp</i>le way,
the basic structure of an HTML document.
</body>
</html>
321

3.3.2. Sample Tags
<html>
<a href=”http://www.oreilly.com/catalog.html”>
<ul compact>
<ul compact=”compact”>
<input type=text name=filename size=24 maxlength=80>
<link title=”Table of Contents”>
</html>
3323
3.3.4. Proper and Improper Nesting
<html>
<body>
This is some text in the body, with a
<a href=”another_doc.html”>link, a portion of which
is <b>set in bold</b></a>
</body>
</html>
3343

3.6.1.1. The dir attribute
<html dir=rtl>
<head>
<title>Display Directions</title>
</head>
<body>
This is how IE 5 renders right-to-left directed text.
</body>
</html>

361113.7.2. The <title> Tag
<html>
<head>
<title>HTML and XHTML: The Definitive Guide</title>
</head>
</html>
3721

HTML & XHTML: The Definitive Guide, 4th Edition

Chapter 7. Formatted Lists
7.1.1. The <ul> Tag
<html>
<body>
Popular Kumquat recipes:
<ul>
<li>Pickled Kumquats</li>
<li>’Quats and ‘Kraut (a holiday favorite!)</li>
<li>’Quatshakes</li>
</ul>
There are so many more to please every palate!
</body>
</html>

7112

7.2.1. The <ol> Tag
<html>
<body>
<h3>Pickled Kumquats</h3>
Here’s an easy way to make a delicious batch of pickled ‘quats:
<ol>
<li>Rinse 50 pounds of fresh kumquats</li>
<li>Bring eight gallons white vinegar to rolling boil</li>
<li>Add kumquats gradually, keeping vinegar boiling</li>
<li>Boil for one hour, or until kumquats are tender</li>
<li>Place in sealed jars and enjoy!</li>
</ol>
</body>
</html>

7214

7.2.1.1. The start attribute
<html>
<body>
<ol start=5>
<li> This is item number 5.</li>
<li> This is number six!</li>
<li> And so forth…</li>
</ol>
</body>
</html>

72112

7.2.1.2. The type attribute
<html>
<body>
<ol start=8 type=”i”>
<li> This is the Roman number 8.
<li> The numerals increment by 1.
<li> And so forth…
</ol>
</body>
</html>

72122

7.3.1.1. The type attribute
<html>
<body>
<ol>
<li type=A>Changing the numbering type</li>
<li type=I>Uppercase Roman numerals</li>
<li type=i>Lowercase Roman numerals</li>
<li type=1>Plain ol’ numbers</li>
<li type=a>Doesn’t alter the order.</li>
<li> &lt;– But, although numbering continues sequentially,</li>
<li> types don’t persist. See? I should’ve been a “g”!</li>
</ol>
</body>
</html>

73112

7.3.1.2. The value attribute
<html>
<body>
<ol>
<li>Item number 1</li>
<li>And the second</li>
<li value=9> Jump to number 9</li>
<li>And continue with 10…</li>
</ol>
</body>
</html>


73122

7.4.1. Nested Unordered Lists

<html><body><ul> 
<li>Morning Kumquat Delicacies 
<ul><li>Hot Dishes    
<ul><li>Kumquat omelet</li>      
<li>Kumquat waffles      
<ul><li>Country style</li>
<li>Belgian</li>  
</ul></li>  
 <li>Kumquats and toast</li>    
</ul></li>   
<li>Cold Dishes    
<ul><li>Kumquats and cornflakes</li>     
<li>Pickled Kumquats</li><li>Diced Kumquats</li>   
</ul></li> </ul> </li></ul></body></html>
7411

7.4.2. Nested Ordered Lists

<html>
<body><ol type="A"> 
<li>A History of Kumquats</li>  <ol type="1">   
<li>Early History</li>    <ol type="a">      
<li>The Fossil Record</li>      
<li>Kumquats: The Missing Link?</li>  
 </ol>    <li>Mayan Use of Kumquats</li>  
 <li>Kumquats in the New World</li> 
</ol>  <li>Future Use of Kumquats</li></ol>
</body>
</html>
7421

7.5.1. The <dl> Tag
<html>
<body>
<h3>Common Kumquat Parasites</h3>
<dl>
<dt>Leaf mites</dt>
<dd>The leaf mite will ravage the Kumquat tree, stripping it
of any and all vegetation.</dd>
<dt>Trunk dropsy</dt>
<dd>This microscopic larvae of the common opossum
chigger will consume the structural elements of the
tree trunk, causing it to collapse inward.</dd>
</dl>
</body>
</html>

751

7.7.1. The <dir> Tag (Deprecated)
<html>
<body>
The distribution tape has the following files on it:
<dir>
<li><code>README</code></li>
<li><code>Makefile</code></li>
<li><code>main.c</code></li>
<li><code>config.h</code></li>
<li><code>util.c</code></li>
</dir>
</body>
</html>

771

7.8.1. The <menu> Tag (Deprecated)
<html>
<body>
Some popular kumquat recipes include:
<menu>
<li>Pickled Kumquats</li>
<li>’Quats and ‘Kraut (a holiday favorite!)</li>
<li>’Quatshakes</li>
</menu>
There are many more to please every palate!
</body>
</html>

781

Blog pada WordPress.com. | Tema: Motion oleh volcanic.
Ikuti

Get every new post delivered to your Inbox.