W W Orking with XHTML
Total Page:16
File Type:pdf, Size:1020Kb
Tutorial 9 1 E-- ww orking with XHTML Creating a Well-Formed, Valid Document I Case I Wizard Works Fireworks I Wizard Works is one of the largest sellers of brand-name and customized fire- works in the central states. Its Web site produces the bulk of the company's sales. Tom Blaska, the head of advertising for Wizard Works, helps develop the content and design of the company's Web site. Because the Web site has been around for many years, some of the code dates back to the earliest versions of HTML. Tom would like the Web site code to be updated to reflect current stan- dards and practices. Specifically, he wants you to look into rewriting the Web site code in XHTML rather than HTML. He also would like you to find ways ta verify that the code used by Wizard Works meets XHTML standards. rlReview dtd-list.txt dtd-list.txt breaktxt.htm dtd-list.txt casttxt.htm address.txt workstxt.htm founttxt.htm dinnrtxt.htm gargtxt.htm dtd-list.txt astro.txt wwtxt.css + 2 graphic dtd-list.txt + 5 graphic + 6 graphic chem.txt + 4 graphic files lunchtxt.htm files files dtd-list.txt files + 4 graphic hebdtxt.htm + 1 graphic files hightxt-htm file laketxt.htm elect.txt scottxt. htm eng.txt + 4 HTML physics.txt files HTML 51 HTML and XHTML I Tutorial 9 Working with XHTA I Introducing XHTML he suggests that puupgrade the hame page file Icr XHTML standards MreCD ta the rest the Web site, ww.css, respectively, in the same folder. ) 2. Open works.htm in your Web browser. Figure 9-1 shows the current layout and design of the page. I Figure 9-1 ) Wizard Works home page We~~f~orlnbbqmhc1~p"'Otr~~~~~hank~lo dcsisnadagpbeym~.aifyo.~b~yoooan~pety.ar~~ dcsigoash.vcukaedlbebea~fadr~Wekmsdci~fayooebq~hfaddvay bcdm-lmme We&~e~~addrpeyrfaspcianedrPbawcmgcC~adorrdcsign~rnwe a~~yonspcia~Besmro~&spsalcvcd~ertytoemm~ddnry WdWm4311T-W LhM KV41105 W]W&31%¶ history of the language. The beginnings of XHTML go back to SGML SGML Standard Generalized Markup Language or SCML is a language introduced in 1980 that describes the structure and content of documents or any type of information that is read- able by machines. SGML is device-independent and system-independent, meaning that documents written in SGML can be used, in theory, on almost any type of device under almost any type of operating system. SGML has been and remains the chosen vehicle for creating structured documents in businesses and government organizations of all sizes. Think of the daunting task involved in documenting all of the parts used in a jet airplane while at the same time organizing those documents so that engineers, mechanics, and developers can use them to quickly retrieve and edit information they need. SGML pro- vides tools to manage documentation projects of this magnitude. However, because of its power, scope, and flexibility, SGML is a difficult language to learn and apply. The official specification for SGML is over 150 pages long and covers some scenarios and cases that are rarely encountered by even the most experienced utorial9 Working with XHTML I HTML and XHTML\ HTML 527 1 is limited to organizations that can afford ( SGML environments. For example, SGML re Web page authors need a language that WLas an SGML Application ! i$more often used in creating SGML applications, which are markup languages klmbased on the SGML architecture and that can be applied to specific, not general, Pf information. One such SGML application is HTML. Because HTML is an SGML on, it shares several of the properties of SGML, such as device-independence, why the same Web page can be rendered by PCs, cell phones, printers, and blem with HTML that you may have noticed is that various Web browsers lped their own unique flavors of HTML to provide customers with new and useful bsnot available with other browsers. For example, the Netscaw browser saw a need that i;lcluded the fraheset and frame ele- HTML at that time. Likewise, Microsoft saw r internal frames and introduced the iframe element into Internet Explorer- innovation that represented a departure from standard HTML. Although these ns were later adopted into the official HTML specifications by the World Wide nsortium (W3C), many other extensions were not adopted-for example, lnternet marquee element used to create blocks of scrolling text. The result can some- confusing mixture of competing HTML standardme kind of HTML for each and, even worse, for each browser version. Although the innovations offered by , Microsoft, and others certainly increased the scope and power of HTML, they the expense of clarity. Web designers could no longer create Web sites without a lot of time and effort to ensure their sites worked across various browsers and be applied inconsistently. For example, the :ations because the hl element has not t&l>~eb Page Title bugh' this code does not follow the correct syntax, most browsers render it correctly. ise, the following code would likely be interpreted correctly even though the col- attribute value is not enclosed in quotation marks: k? colspan=2sHeading</td> bough a browser that is verv forgiving of mistakes in svntax might seem beneficial to ~sionas different ~ibpages employ HTML also affects the browser design. By mak- { allowances for inconsistently applied HTML code, the source code for tLe browser ~t be larger and more complex to deal with all contingencies. This can become an tre for browsers that run on handheld devices, which are more limited in the space y allot for software. So it is actually better for everyone if Web page code adheres to itain standards for content and structure. The path to a cleaner version of HTML mlved rewriting HTML in terms of XML. C HTML and XHTML Tutorial 9 Working with XHTML XML and XHTML specific needs. For example, a business might design an XML document that contains elements for recording inventory and pricing data. This code <work> <work-number>K. 33l</work-number> <work-title>Piano Sonata in A Major</work-title> </work> <identification> <creator type=l~composerl'>WolfgangAmadeus Mozart</creator> <rights>Copyright 2003 Recordare LLCc/rights> </identification> I and XML, the W3C maintains the specifications and standards for XHTML. The marizes these versions. I I Figure 9-2 Version Date Rebased Description XHTML brings the rigor of XML to Web pages and standards for more robust Web content on a wide The most didely supported version of XHTML is XHTML 1.0, with the specificatio most closely matching the specifications for HTML 4.0 (the latest W3C version of HT at the time of this writing). XHTML 1 .I is a restructuring of XHTML 1.0 in which diffe elements are placed within modules. This allows browsers to support only the portion the XHTML language that are relevant to their needs. Figure 9-3 describes some of the different modules in XHTML 1.l. 1 Tutorial 9 Working with XHTML HTML and XHTML HTML 529 : 1 XHTML 1.1 modules Figure 9-3 11 ~Mh "m supported Elements d - Structure Used to define the basic structure of the body, head, html, title document Metainformatim Used to add meta-information to the rneta document Used for text content abbr, acronym, address, blockquote, br, cite, code, dfn, div, em, hl, h2, h3, h4, h5, h6, kbd, p, pre, q, samp, span, strow, var elements b, big, hr, i, small, sub, sup, tt dl, dt, dd, d,ul, li ,!Object Used for embedded obiects object, pararn mae Used for inline imaaes imci 1 ient-side Used for client-side image maps area, map frameset, frame, noframes ame Used for inline frames iframe rms Used for Web forms buttan, fieldset, form. input, label, leq- end, select, optgrmp, option, textarea 1 Fable Used for Web tables caption, col, damup,-. table, tbody, td, I tfoot, th, thead, tr I riptinq Used for addina scripts to the dasument noscript, scrlpt I - - yle Sheet Used for acc&ing style sheets style yle Attribute Used for adding the style attribute to attribute: style attribute (deprecated) individual elements Used for deprecatede dements and attributes menu, s, strike, uattributes: align, alink, I For example, an aural browser that works only with text might support only modules bat deal with text content, and not modules that deal with images or embedded objects. eftis enables browser developers to reduce the sizes of their applications to fit the uirements of specific devices. Browser developers can also use XHTML Basic, a ver- n of XHTML 1.1 that limits the modules to those useful with handheld devices. HTML 2.0 is still in draft form and so it is not supported in the Web community. When pleted, this version is expected to represent a great departure from previous versions of ML and HTML. In fact, documents written in XHTML 2.0 will not be backward- atible with earlier XHTML versions-a point that concerns many developers. The devel- nt of XHTML 2.0 will likely require the development of new XHTML modules or ions to existing XHTML modules. For this reason, a great deal of development effort is going into HTML 5.0 (and its XML version, XHTML 5.0), which will provide more sup- for multimedia elements as well as features for entering and retrieving data. the end, any future version of XHTML must have wide-ranging browser support e it can be easily adopted for general use. Browser support does not occur auto- nor is acceptance of any revisions to XHTML uniform across all browsers. So after the specifications for new versions of XHTML are finalized, it will be many y replaced.