Tải bản đầy đủ (.pdf) (50 trang)

Tài liệu Web Programming with HTML, XHTML, and CSS Second Edition- P15 ppt

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (827.92 KB, 50 trang )

image
uri-list vnd.in3d.spot vnd.sun.j2me.app-descriptor
vnd.abc vnd.IPTC.NewsML vnd.wap.si
vnd.curl vnd.IPTC.NITF vnd.wap.sl
vnd.DMClientScript vnd.latex-z vnd.wap.wml
vnd.fly vnd.motorola.reflex vnd.wap.wmlscript
vnd.fmi.flexstor vnd.ms-mediapackage xml
vnd.in3d.3dml vnd.net2phone.commcenter.command xml-external-parsed-entity
bmp tiff-fx vnd.mix
cgm vnd.cns.inf2 vnd.ms-modi
g3fax vnd.djvu vnd.net-fpx
gif vnd.dwg vnd.sealed.png
ief vnd.dxf vnd.sealedmedia.softseal.gif
jpeg vnd.fastbidsheet vnd.sealedmedia.softseal.jpg
naplps vnd.fpx vnd.svf
png vnd.fst vnd.wap.wbmp
prs.btif vnd.fujixerox.edmics-mmr vnd.xiff
prs.pti vnd.fujixerox.edmics-rlc x-portable-pixmap
t38 vnd.globalgraphics.pgb x-xbitmap
tiff vnd.microsoft.icon
671
Appendix H: MIME Media Types
59313bapp08.qxd:WroxPro 3/23/08 2:35 PM Page 671
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
multipart
audio
32kadpcm G726-24 MP4A-LATM
AMR G726-32 mpa-robust
AMR-WB G726-40 mpeg
basic G728 mpeg4-generic
CN G729 parityfec


DAT12 G729D PCMA
dsr-es201108 G729E PCMU
DVI4 GSM prs.sid
EVRC GSM-EFR QCELP
EVRC0 L8 RED
EVRC-QCP L16 SMV
G722 L20 SMV0
G.722.1 L24 SMV-QCP
G723 LPC telephone-event
G726-16 MPA tone
alternative form-data report
appledouble header-set signed
byteranges mixed voice-message
digest parallel
encrypted related
672
Appendix H: MIME Media Types
59313bapp08.qxd:WroxPro 3/23/08 2:35 PM Page 672
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
video
BMPEG MP4V-ES vnd.mpegurl
BT656 MPV
vnd.nokia.interleaved-multime
dia
CelB mpeg vnd.objectvideo
DV mpeg4-generic vnd.sealed.mpeg1
H261 nv vnd.sealed.mpeg4
H263 parityfec vnd.sealed.swf
H263-1998 pointer vnd.sealedmedia.softseal.mov
H263-2000 quicktime vnd.vivo

JPEG SMPTE292M x-sgi-movie
MP1S vnd.fvt x-msvideo
MP2P vnd.motorola.video
MP2T vnd.motorola.videop
VDVI vnd.nokia.mobile-xmf vnd.sealedmedia.softseal.mpeg
vnd.3gpp.iufp vnd.nortel.vbk vnd.vmx.cvsd
vnd.cisco.nse vnd.nuera.ecelp4800 x-aiff
vnd.cns.anp1 vnd.nuera.ecelp7470 x-midi
vnd.cns.inf1 vnd.nuera.ecelp9600 x-mod
vnd.digital-winds vnd.octel.sbc x-mp3
vnd.everad.plj vnd.qcelp — deprecated, use
audio/qcelp
x-wav
vnd.lucent.voice vnd.rhetorex.32kadpcm
673
Appendix H: MIME Media Types
59313bapp08.qxd:WroxPro 3/23/08 2:35 PM Page 673
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
message
model
application
activemessage cpl+xml eshop
andrew-inset cybercash font-tdpfr
applefile dca-rft http
atomicmail dec-dx hyperstudio
batch-SMTP dicom iges
beep+xml dvcs index
cals-1840 EDI-Consent index.cmd
cnrp+xml EDIFACT index.obj
commonground EDI-X12 index.response

iges vnd.gdl vnd.parasolid.transmit.binary
mesh vnd.gs-gdl vnd.parasolid.transmit.text
vnd.dwf vnd.gtw vnd.vtu
vnd.flatland.3dml vnd.mts vrml
CPIM http s-http
delivery-status news sip
disposition-notification partial sipfrag
external-body rfc822
674
Appendix H: MIME Media Types
59313bapp08.qxd:WroxPro 3/23/08 2:35 PM Page 674
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Continued
index.vnd pkcs10 sgml-open-catalog
iotp pkcs7-mime sieve
ipp pkcs7-signature slate
isup pkix-cert timestamp-query
mac-binhex40 pkixcmp timestamp-reply
macwriteii pkix-crl tve-trigger
marc pkix-pkipath vemmi
mathematica postscript vnd.3gpp.pic-bw-large
mpeg4-generic prs.alvestrand.titrax-sheet vnd.3gpp.pic-bw-small
msword prs.cww vnd.3gpp.pic-bw-var
news-message-id prs.nprend vnd.3gpp.sms
news-transmission prs.plucker vnd.3M.Post-it-Notes
ocsp-request qsig vnd.accpac.simply.aso
ocsp-response reginfo+xml vnd.accpac.simply.imp
octet-stream remote-printing vnd.acucobol
oda riscos vnd.acucorp
ogg rtf vnd.adobe.xfdf

parityfec sdp vnd.aether.imp
pdf set-payment vnd.amiga.ami
pgp-encrypted set-payment-initiation vnd.anser-web-certificate-issue-initiation
pgp-keys set-registration vnd.anser-web-funds-transfer-initiation
pgp-signature set-registration-initiation vnd.audiograph
pidf+xml sgml vnd.blueice.multipass
675
Appendix H: MIME Media Types
59313bapp08.qxd:WroxPro 3/23/08 2:35 PM Page 675
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
vnd.bmi vnd.ecowin.chart vnd.fujitsu.oasysgp
vnd.businessobjects vnd.ecowin.filerequest vnd.fujitsu.oasysprs
vnd.canon-cpdl vnd.ecowin.fileupdate vnd.fujixerox.ddd
vnd.canon-lips vnd.ecowin.series vnd.fujixerox.docuworks
vnd.cinderella vnd.ecowin.seriesrequest vnd.fujixerox.docuworks.binder
vnd.claymore vnd.ecowin.seriesupdate vnd.fut-misnet
vnd.commerce-battelle vnd.enliven vnd.genomatix.tuxedo
vnd.commonspace vnd.epson.esf vnd.grafeq
vnd.cosmocaller vnd.epson.msf vnd.groove-account
vnd.contact.cmsg vnd.epson.quickanime vnd.groove-help
vnd.criticaltools.wbs+xml vnd.epson.salt vnd.groove-identity-message
vnd.ctc-posml vnd.epson.ssf vnd.groove-injector
vnd.cups-postscript vnd.ericsson.quickcall vnd.groove-tool-message
vnd.cups-raster vnd.eudora.data vnd.groove-tool-template
vnd.cups-raw vnd.fdf vnd.groove-vcard
vnd.curl vnd.ffsns vnd.hbci
vnd.cybank vnd.fints vnd.hhe.lesson-player
vnd.data-vision.rdz vnd.FloGraphIt vnd.hp-HPGL
vnd.dna vnd.framemaker vnd.hp-hpid
vnd.dpgraph vnd.fsc.weblaunch vnd.hp-hps

vnd.dreamfactory vnd.fujitsu.oasys vnd.hp-PCL
vnd.dxr vnd.fujitsu.oasys2 vnd.hp-PCLXL
vnd.ecdis-update vnd.fujitsu.oasys3 vnd.httphone
676
Appendix H: MIME Media Types
59313bapp08.qxd:WroxPro 3/23/08 2:35 PM Page 676
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Continued
vnd.hzn-3d-crossword vnd.japannet-setstore-wakeup vnd.lotus-notes
vnd.ibm.afplinedata vnd.japannet-verification vnd.lotus-organizer
vnd.ibm.electronic-media vnd.japannet-verification-
wakeup
vnd.lotus-screencam
vnd.ibm.MiniPay vnd.jisp vnd.lotus-wordpro
vnd.ibm.modcap vnd.kde.karbon vnd.mcd
vnd.ibm.rights-management vnd.kde.kchart vnd.mediastation.cdkey
vnd.ibm.secure-container vnd.kde.kformula vnd.meridian-slingshot
vnd.informix-visionary vnd.kde.kivio vnd.micrografx.flo
vnd.intercon.formnet vnd.kde.kontour vnd.micrografx.igx
vnd.intertrust.digibox vnd.kde.kpresenter vnd.mif
vnd.intertrust.nncp vnd.kde.kspread vnd.minisoft-hp3000-save
vnd.intu.qbo vnd.kde.kword vnd.mitsubishi.misty-guard
.trustweb
vnd.intu.qfx vnd.kenameaapp vnd.Mobius.DAF
vnd.ipunplugged.rcprofile vnd.kidspiration vnd.Mobius.DIS
vnd.irepository.package+xml vnd.koan vnd.Mobius.MBK
vnd.is-xpr vnd.liberty-request+xml vnd.Mobius.MQY
vnd.japannet-directory-
service
vnd.llamagraphics.life-

balance.desktop
vnd.Mobius.MSL
vnd.japannet-jpnstore-wakeup
vnd.llamagraphics.life-
balance.exchange+xml
vnd.Mobius.PLC
vnd.japannet-payment-wakeup
vnd.lotus-1-2-3 vnd.Mobius.TXF
vnd.japannet-registration vnd.lotus-approach vnd.mophun.application
vnd.japannet-registration-
wakeup
vnd.lotus-freelance vnd.mophun.certificate
677
Appendix H: MIME Media Types
59313bapp08.qxd:WroxPro 3/23/08 2:35 PM Page 677
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
vnd.motorola.flexsuite vnd.netfpx vnd.pvi.ptid1
vnd.motorola.flexsuite.adsi vnd.noblenet-directory vnd.pwg-multiplexed
[RFC3391]
vnd.motorola.flexsuite.fis vnd.noblenet-sealer vnd.pwg-xhtml-print+xml
vnd.motorola.flexsuite.gotap vnd.noblenet-web vnd.Quark.QuarkXPress
vnd.motorola.flexsuite.kmr vnd.novadigm.EDM vnd.rapid
vnd.motorola.flexsuite.ttc vnd.novadigm.EDX vnd.s3sms
vnd.motorola.flexsuite.wem vnd.novadigm.EXT vnd.sealed.doc
vnd.mozilla.xul+xml vnd.obn vnd.sealed.eml
vnd.ms-artgalry vnd.osa.netdeploy vnd.sealed.mht
vnd.ms-asf vnd.palm vnd.sealed.net
vnd.mseq vnd.paos.xml vnd.sealed.ppt
vnd.ms-excel vnd.pg.format vnd.sealed.xls
vnd.msign vnd.pg.osasli

vnd.sealedmedia.softseal.htm
l
vnd.ms-lrm vnd.picsel vnd.sealedmedia.softseal.pdf
vnd.ms-powerpoint vnd.powerbuilder6 vnd.seemail
vnd.ms-project vnd.powerbuilder6-s vnd.shana.informed.formdata
vnd.ms-tnef vnd.powerbuilder7 vnd.shana.informed
.formtemplate
vnd.ms-works vnd.powerbuilder7-s vnd.shana.informed
.interchange
vnd.ms-wpl vnd.powerbuilder75 vnd.shana.informed.package
vnd.musician vnd.powerbuilder75-s vnd.smaf
vnd.music-niff vnd.previewsystems.box vnd.sss-cod
vnd.nervana vnd.publishare-delta-tree vnd.sss-dtf
678
Appendix H: MIME Media Types
59313bapp08.qxd:WroxPro 3/23/08 2:35 PM Page 678
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
vnd.sss-ntf vnd.vectorworks vnd.yamaha.smaf-audio
vnd.street-stream vnd.vidsoft.vidconference vnd.yamaha.smaf-phrase
vnd.svd vnd.visio
vnd.yellowriver-custom-menu
vnd.swiftview-ics vnd.visionary watcherinfo+xml
vnd.triscape.mxs vnd.vividence.scriptfile whoispp-query
vnd.trueapp vnd.vsf whoispp-response
vnd.truedoc vnd.wap.sic wita
vnd.ufdl vnd.wap.slc wordperfect5.1
vnd.uiq.theme vnd.wap.wbxml x400-bp
vnd.uplanet.alert vnd.wap.wmlc x-debian-package
vnd.uplanet.alert-wbxml vnd.wap.wmlscriptc x-gzip
vnd.uplanet.bearer-choice vnd.webturbo x-java

vnd.uplanet.bearer-
choice-wbxml
vnd.wqd x-javascript
vnd.uplanet.cacheop vnd.wrq-hp3000-labelled x-msaccess
vnd.uplanet.cacheop-wbxml vnd.wt.stf x-msexcel
vnd.uplanet.channel vnd.wv.csp+xml x-mspowerpoint
vnd.uplanet.channel-wbxml vnd.wv.csp+wbxml x-rpm
vnd.uplanet.list vnd.wv.ssp+xml x-zip
vnd.uplanet.list-wbxml vnd.xara xhtml+xml
vnd.uplanet.listcmd vnd.xfdl xml
vnd.uplanet.listcmd-wbxml vnd.yamaha.hv-dic xml-dtd
vnd.uplanet.signal vnd.yamaha.hv-script xml-external-parsed-entity
vnd.vcx vnd.yamaha.hv-voice zip
679
Appendix H: MIME Media Types
59313bapp08.qxd:WroxPro 3/23/08 2:35 PM Page 679
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
59313bapp08.qxd:WroxPro 3/23/08 2:35 PM Page 680
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
I
Deprecated and
Browser-Specific Markup
As the versions of HTML and XHTML have developed, quite a lot of markup has been deprecated,
which means it has either already been removed from XHTML specifications or that it will be removed
in coming versions. While you will still be able to use much of this markup with Transitional XHTML,
Strict XHTML 1.0 has already removed most of the elements, attributes, and styles that you can read
about in this appendix.
I have included it in this book, despite the fact that the markup is deprecated or out-of-date, because
you are likely to come across it in other people’s code, and on very rare occasions you might need
to resort to some of it in order to get a specific job done (for example, if it has to work in very old

browsers such as IE 3 and Netscape 3), and some of these browsers will not support what you want
to do with CSS.
In addition to deprecated markup, you will also see some of the browser-specific markup that you
may well come across. This is markup that Microsoft or Netscape (and in some cases both companies)
added to its browsers to allow users to do more things than its competitors — but these elements
and attributes never made it into the HTML recommendations, and are therefore referred to as
browser-specific markup.
So not only does this appendix help you deal with markup you come across that has been deprecated,
but you might also use some techniques to get the result you want. This appendix covers the following:

Elements and attributes that have been deprecated in recent versions of HTML and XHTML
❑ Specifying font appearances without using CSS
❑ Controlling backgrounds without using CSS
❑ Controlling presentations of links, lists, and tables without using CSS
❑ Elements and attributes that control the formatting of a document
❑ Elements, attributes, and styles that Microsoft added to IE (but that are not supported by
other browser manufacturers)

Elements, attributes, and styles that Netscape added to Navigator (but that are not supported
by other browser manufacturers)
59313bapp09.qxd:WroxPro 3/23/08 3:04 PM Page 681
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Before you look at any of this markup, however, a quick word on why a good part of an appendix is
deprecated markup.
Why Deprecated Markup Exists
In the first chapter, I explained how XHTML 1.0 was created after its predecessor (HTML) had reached
version 4.01. With each version of HTML, new elements and attributes are added or old ones removed.
These changes have been necessary, not only because web page authors have wanted to create increasingly
complicated pages, but also because the types of browsers (also known as clients) accessing the Internet
have changed.

While you used to be able to browse the web only on desktop computers, lots of new devices are going
online, and these new devices are part of the reason why markup that describes the content of a document
(headings, paragraphs, and so on) has been separated from the presentation rules.
In older versions of HTML, before CSS was introduced, HTML contained markup that could be used to
control the presentation of a web page (such as the
<font>
element that would control the font used in a
document, or the
bgcolor
attribute that would set the background color of a page). The separation of style
from content and the introduction of CSS were the largest sources of deprecated markup.
Unfortunately, the older browsers that were built before CSS and other more recent markup simply will
not understand the newer ways of doing things, and if you ever have to create a web site for IE 3 or
Netscape 3 you will have to think very carefully about whether you use CSS (which they barely under-
stand, if at all) or whether you should use these deprecated elements and attributes. In reality, it is very
unlikely that you will have to create markup that would work in such an old browser; however, you
might need to understand how a page written back then works.
Older Pages Break Many Rules
You should be aware that a lot of the pages you see on the Web probably break a lot of the rules you have
learned in this book so far. You will see element and attribute names in upper- and lowercase, you will
see missing quotation marks on attribute values, even attributes without values, and you will see elements
that do not have closing tags. You will see pages without
DOCTYPE
declarations and pages littered with
deprecated markup. Keep in mind, however, that many of the pages that break the rules you have learned
might have been written when the rules were not as strict, and at the time of writing the code may have
been perfectly acceptable.
Even if a page with bad or deprecated markup renders fine in your browser, it’s still wise to avoid bad
habits at all costs; otherwise your pages will not be viewable by as many browsers in the future.
It is not just humans who wrote code that might be frowned upon these days. The early versions of author-

ing
tools such as Microsoft FrontPage and Macromedia Dreamweaver sometimes generated code that had
strange capitalization or missing quotation marks, and featured attributes without values. This certainly
does not make it okay to follow their lead. The first versions of these programs were written before XHTML
came along with its stricter rules (which were discussed in Chapter 1). Older browsers are very forgiving
of code that is not written correctly and have been designed to render a page anyway. But that is one of
682
Appendix I: Deprecated and Browser-Specific Markup
59313bapp09.qxd:WroxPro 3/23/08 3:04 PM Page 682
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
the main reasons why browsers have been increasing in size — future browsers will not necessarily be so
forgiving.
You have been warned that this appendix will contain some odd things, but if you remember to stick to
the principles you have learned in this book (and don’t miss quotes, attribute values, and closing elements
or follow the bad habits others have) your pages will be available for many more people and your skills
will be more marketable.
Fonts
In this section, you learn about several elements (and their attributes) that affect the appearance of text
and fonts, all of which have been deprecated.
The <font> Element
The
<font>
element was introduced in HTML 3.2 and deprecated in HTML 4.0, but is still widely used
today. It allows you to indicate the typeface, size, and color of font the browser should display between
the opening
<font>
and closing
</font>
tags. You could probably find many sites littered with
<font>

tags, one for each time you see the style of text change on the page.
The table that follows shows the three attributes the
<font>
element relies upon.
The following is an example of how the
<font>
element would have been used (
ai_eg01.html
). You
can see that there are three occurrences of the
<font>
element:
<html>
<head>
<title>Example of &lt;font&gt; Element</title>
</head>
<body>
<p>This is the browser’s default font.</p>
<font face=”arial, verdana, sans-serif” size=”2”>
<h1>Example of the &lt;font&gt; Element</h1>
Attribute Name Use Values
face
Specify the typeface that should
be used
Name of the typeface to use (can
include more than one name in
order of preference)
size
Specify the size of the font A number between 1 and 7 where 1
is the smallest font size and 7 is the

largest font size
color
Specify the color of the font A color name or hex value (see
Appendix D)
683
Appendix I: Deprecated and Browser-Specific Markup
59313bapp09.qxd:WroxPro 3/23/08 3:04 PM Page 683
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
<p><font size=”4” color=”darkgray”>Here is some size 3 writing
in the color called darkgray. The typeface is determined by the
previous &lt;font&gt; element that contains this paragraph.</font></p>
<p><font face=”courier” size=”2” color=”#000000”>Now here is a courier
font, size 2, in back</font></p>
</font>
</body>
</html>
The result of this example is shown in Figure I-1.
Figure I-1
As you can see from Figure I-1, all the writing within a
<font>
element follows the rules laid down in the
attributes of the opening
<font>
tag. The first paragraph is in the browser’s default font (which is prob-
ably a size 3 Times family font in black). The first
<font>
element appears directly after this paragraph,
and contains the rest of the page. This first
<font>
element acts like a default setting for all but the first

paragraph in this page. The element is not closed until just before the closing
<body>
tag, and therefore
the remainder of the document should be in an Arial typeface.
As you can see, the name of the Arial typeface is followed by the typeface Verdana; this is supposed to be
a second choice if Arial is not available. Then if Verdana is not available, the browser’s default sans-serif
font should be used:
<font face=”arial, verdana, sans-serif” size=”2”>
This
<font>
element also indicates that the default size of the text in the rest of the document should be
size 2. Note that this
<font>
element does not override the size of the
<h1>
element, but it does affect
the typeface used — the heading is written in Arial.
While this
<font>
element is acting as a default for most of the page, if you want a particular part of the
page to have any other font properties, you can indicate so in another
<font>
element.
You can see in the second paragraph that the color and size of font are changed to dark gray and size 4.
<p><font size=”4” color=”darkgray”>Here is some size 4 darkgray
writing</font></p>
684
Appendix I: Deprecated and Browser-Specific Markup
59313bapp09.qxd:WroxPro 3/23/08 3:04 PM Page 684
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

The third paragraph then uses a different typeface, a smaller size, and black:
<p><font face=”courier” size=”2” color=”#000000”>Now here is a courier
font, size 2, in back</font></p>
Note that you may have to use
<font>
elements inside
<td>
and
<th>
elements, as the styles specified
outside tables are not inherited by the text inside cells. Figure I-2 shows you the different font sizes from
1 to 7 (
ai_eg02.html
).
Figure I-2
Font sizes can change slightly from browser to browser, so you cannot rely on them to be exactly the
same number of pixels tall or wide in a layout.
The preferred method with CSS would be to use the
font-family
,
font-size
, and
color
properties
on the element containing the text that you wanted to style. You learned about these CSS properties in
Chapter 7.
The text Attribute
The
text
attribute is used on the

<body>
element to indicate the default color for text in the document; it was
deprecated in HTML 4. Its value should be either a color name or a hex color. For example (
ai_eg03.html
):
<body text=”#999999”>
This text should be in a different color than the next bit
<font color=”#000000”>which is black</font>, and now back to gray.
</body>
You can see the result in Figure I-3.
Figure I-3
685
Appendix I: Deprecated and Browser-Specific Markup
59313bapp09.qxd:WroxPro 3/23/08 3:04 PM Page 685
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
The <basefont> Element
The
<basefont>
element is supposed to set a default font size, color, and typeface for any parts of the doc-
ument
that are not otherwise contained within a
<font>
element. You can then use the
<font>
elements
to override the
<basefont>
settings. However, this is not supported in Firefox or Netscape 6, and other
browsers do not always obey the settings in tables or headings.
The attributes that the

<basefont>
element takes are exactly the same as for the
<font>
element, which
you’ve just seen. And again, elements such as the heading elements will retain their own size.
You can also set the size of fonts relative to the size of the
<basefont>
by giving them a value of
+1
for a
size larger or
-2
for two sizes smaller (on the same scale from 1 to 7).
You can see these effects by revisiting the last example, and making some changes — the changes are
highlighted (
ai_eg04.html
):
<html>
<head>
<title>Example of &lt;basefont&gt; Element</title>
</head>
<body>
<basefont face=”arial, verdana, sans-serif” size=”2” color=”#ff0000”>
<p>This is the page’s default font.</p>
<h2>Example of the &lt;basefont&gt; Element</h2>
<p><font size=”+4” color=”darkgray”>Here is some darkgray text
four sizes larger</font></p>
<p><font face=”courier” size=”-1” color=”#000000”>Here is a courier
font, a size smaller, in black</font></p>
</body>

</html>
You can see the result in Figure I-4 shown in Internet Explorer (because the example does not work in
Firefox).
Figure I-4
686
Appendix I: Deprecated and Browser-Specific Markup
59313bapp09.qxd:WroxPro 3/23/08 3:04 PM Page 686
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
As you can see, the default font now takes on the properties specified in the
<basefont>
element; it is
red, size 2, and uses the Arial typeface.
The paragraph after the
<h2>
element uses a font size four sizes larger than the default size and is gray
text, whereas the following paragraph uses a font one size smaller than the default font — you can also
see that the color of this font is black (overriding the default).
Because this element was deprecated in HTML 4, the preferred option is to use CSS styles attached to the
<body>
element to set default font properties for the document.
The <s> and <strike> Elements
Both the
<s>
and
<strike>
elements were added to HTML in version 3.2 and deprecated in version 4.
They indicate that their content should have a strikethrough style. For example (
ai_eg05.html
):
<s>This text will have a line through it</s>

<strike>This text will also have a line through it.</strike>
You can see the results in Figure I-5.
Figure I-5
You should now use the
text-decoration
property in CSS, with a value of
strikethrough
, unless you
are trying to indicate deleted content, in which case you should use the
<del>
element.
The <u> Element
The
<u>
element renders its content underlined. It was introduced in HTML 3.2 and deprecated in version 4.
<u>This text should be underlined.</u>
You can see the effect in Figure I-6.
Figure I-6
687
Appendix I: Deprecated and Browser-Specific Markup
59313bapp09.qxd:WroxPro 3/23/08 3:04 PM Page 687
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
You should now use the
text-decoration
property in CSS with a value of
underline
unless you are
trying to indicate added content (when a document has been revised), in which case you should use the
<ins>
element.

The <listing>, <plaintext>, and <xmp> Elements
These three elements are all obsolete; they were introduced in HTML 2 and removed from HTML 4. They
are included here only because you may come across them in old examples.
All three elements display text in a monospaced font as the
<pre>
element does.
The
<xmp>
element was designed for a short snippet of example code, and cannot contain any other markup;
any characters such as angle brackets in element names get displayed as if they are text, so you do not need
to use escape characters for them. It is recommended that the author use a maximum limit of 80 characters
on any one line.
The
<listing>
element meanwhile has a recommended limit of 132 characters per line, and tends to
display text in a small font.
The
<plaintext>
tag indicates that anything following it should appear as plain text, even markup. Because
everything following the
<plaintext>
element is displayed as normal text, including tags, there is no
closing tag (if you tried to use a
</plaintext>
tag, it too would be displayed as normal text).
Here is an example of these three elements (
ai_eg07.html
):
<body>
<h2>Example of the &lt;listing&gt;, &lt;plaintext&gt;, and &lt;xmp&gt;

Elements</h2>
<listing>These words are written inside a &lt;listing&gt; element.</listing>
<xmp>These words are written inside an <xmp> element.</xmp>
<plaintext>These words are written inside a <plaintext>
element.
</body>
You can see the result in Figure I-7. Note how the escape characters in the
<xmp>
element are ignored and not
escaped (this could also contain angle brackets and they would display normally). You will also see the clos-
ing
</body>
and
</html>
tags because anything after the opening
<plaintext>
tag is treated as plain text:
Figure I-7
688
Appendix I: Deprecated and Browser-Specific Markup
59313bapp09.qxd:WroxPro 3/23/08 3:04 PM Page 688
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
The replacements in XHTML are
<pre>
and
<samp>
.
Backgrounds
There were two attributes in HTML that would allow you to change the background of a whole page or
part of it:


bgcolor
, which allowed you to specify a background color on the
<body>
and various table
elements

background
, which allowed you to specify a background image on the
<body>
element
The bgcolor Attribute
The
bgcolor
attribute allowed you to specify a background color for the whole document, or just part
of it. It could be used on the following elements:
<body> <table> <tr> <th> <td>
The value of the attribute should be a color name or hex color, as described in Appendix D.
The following is an example of a document using some different background colors (
ai_eg08.html
):
<html>
<head>
<title>Example of bgcolor Attribute</title>
</head>
<body bgcolor=”#efefef”>
<h2>Example of the bgcolor Attribute</h2>
<table bgcolor=”#999999”>
<tr>
<th bgcolor=”#cccccc”>Heading One</th>

<th bgcolor=”#cccccc”>Heading Two</th>
</tr>
<tr bgcolor=”#f2f2f2”>
<td>Cell One</td>
<td>Cell Two</td>
</tr>
<tr>
<td>Cell Three</td>
<td>Cell Four</td>
</tr>
</body>
</html>
You can see this page in Figure I-8.
689
Appendix I: Deprecated and Browser-Specific Markup
59313bapp09.qxd:WroxPro 3/23/08 3:04 PM Page 689
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Figure I-8
The page has a very light gray background color specified on the
<body>
element. The table then has a
background color, which you can see on the bottom row and all around the edges of the table. This is the
default color for the table. Then you can see that the
bgcolor
attribute is used both on the
<th>
element
(the table headings) and the following
<tr>
element in the first row.

The preferred method of changing background colors now is to use the
background-color
property in CSS.
The background Attribute
The
background
attribute allowed you to specify a background image for the whole page, and its value
should be the URL to the background image (which can be an absolute or relative URL). Netscape and
Microsoft also allowed this attribute to be used on tables to create a background image for the tables.
Here you can see an example of the
background
attribute being used (
ai_eg09.html
):
<html>
<head>
<title>Example of background Attribute</title>
</head>
<body background=”images/background_large.gif” bgcolor=”#f2f2f2”>
<h2>Example of the background Attribute</h2>
</body>
</html>
Note that the
bgcolor
attribute has also been used on the
<body>
element, which will be used if the image
cannot be found. You can see the result of this example in Figure I-9.
Figure I-9
690

Appendix I: Deprecated and Browser-Specific Markup
59313bapp09.qxd:WroxPro 3/23/08 3:04 PM Page 690
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

×