Home > Articles > Web Services > XML

The Trouble with HTML

When we look more closely at what this rapid-fire growth and disregard for rules has done to HTML, we see significant degradation of the initial goal of HTML: to create documents that are readily accessible across browsers, platforms, and user interfaces. In fact, the very reasons HTML came into being were rapidly bastardized in the name of progress.

Is this a bad thing? On the side of innovation's defense, it probably couldn't have happened any other way. That rapid pace was necessary to push the envelope and create the dynamic, wild, and profitable Web we know today.

However, looking around at the amount of HTML out there that is poorly written, it's amazing that Web pages work as well as they do—much less work at all. And although most of the Web does seem to work, the reality is that we are very limited in terms of being able to make progress, to create truly interoperable sites, and to create sites that are both well-designed and authored correctly.

Poorly Written Code

The first and most upsetting thing about the state of HTML is that there is no consistency among the way documents are developed. Whether a person authors HTML by hand or uses a development tool of some kind, code results tend to be as far from the standards as one can imagine.

Think of it this way: If I have two people apply for a job as an HTML author (and this has really happened), and I provide a table and ask the authors to hand code it (see Figure 3.1), each of the individuals will mark it up in a different way. Part of the reason is that HTML itself is somewhat arbitrary. For example, in Listing 3.1, I show one way to mark up the table in Figure 3.1. Listing 3.2 shows another—both equally correct.

Figure 3.1
A simple HTML table for code reproduction.

Listing 3.1 Table Code Example Option 1

<table border="1" cellpadding="0" cellspacing="0" width="50%" align="center">
<tr>
  <th align="left">Fruits</th>
  <th align="left">Vegetables</th>
  <th align="left">Grains</th>
  <th align="left">Proteins</th>
</tr>
<tr>
  <td>Apples</td>
  <td>Green Beans</td>
  <td>Wheat</td>
  <td>Fish</td>
</tr>
<tr>
  <td>Oranges</td>
  <td>Spinach</td>
  <td>Oats</td>
  <td>Chicken</td>
</tr>
<tr>
  <td>Bananas</td>
  <td>Asparagus</td>
  <td>Barley</td>
  <td>Beef</td>
</tr>

</table>

Listing 3.2 Table Code Example Option 2

<div align="center">
<table border="1" cellpadding="0" cellspacing="0" width="50%">
<tr>
  <td><b>Fruits</b></td>
  <td><b>Vegetables</b></td>
  <td><b>Grains</b></td>
  <td><b>Proteins</b></td>
</tr>
<tr>
  <td>Apples</td>
  <td>Green Beans</td>
  <td>Wheat</td>
  <td>Fish</td>
</tr>
<tr>
  <td>Oranges</td>
  <td>Spinach</td>
  <td>Oats</td>
  <td>Chicken</td>
</tr>
<tr>
  <td>Bananas</td>
  <td>Asparagus</td>
  <td>Barley</td>
  <td>Beef</td>
</tr>
</table>

</div>

And these are clean examples! The sad fact is that most individuals—even those who have been writing or producing HTML documents for several years—will not mark up the document in any consistent or mature way. They'd leave out attributes, put in ones that don't belong (or exist), or run into problems because they've always relied on a visual editor to get the job done for them.

Now to be fair, it's important to point out that this lack of consistency and lack of knowledge has very little to do with the integrity of the individuals in question. It has ever so much more to do with the fact that the way HTML has been learned is by the boot-strap method. Early adopters used View Source and picked up others' mistakes. Later on, when visual editors became pervasive and browsers very forgiving, people relied more on what the programs were producing. As long as the page was readable, that's what mattered. And finally, the more forgiving of poor markup browsers became, the less people had to concern themselves with consistent code practices, much less standardized ones.

My goal here is to impress upon you—readers who are obviously interested in what XHTML 1.0 is offering to Web authors—how grave the situation with HTML has become. XHTML 1.0 seeks, through its rigorous syntax and adherence to standard rules, to improve the quality of code. And that quality, at least at this point in history, rests in the hands of the author.

Code for Presentation, Not for Formatting

I'm a designer, interested in color, space, shape, typography, and the impact that a visual display can make on another person. I like things to look good! And, I want them to work properly. But another of the troubles that HTML has had is that it was forced, by default, into being a language of design rather than document structure. I discussed, in brief, the fact that HTML was never intended to be anything but a formatting language for documents in Chapter 1, "Understanding XHTML 1.0." I want to take a closer look at these concepts, and provide examples in this chapter so you can see just how this problem—and those related to it—have escalated concerns about HTML's integrity.

The rapid advancements of the visual Web, and the excitement that surrounded its growth, put a lot of weight on HTML to accommodate design as well as structure. This is seen very clearly in two places: the use of tables for layout; and the introduction of presentational tags such as the font tag.

Let's revisit the table in Figure 3.1. Its purpose is to take tabular information and present it logically. It fulfills the purpose for which tables were brought into HTML.

But not long after, someone figured out that if you remove the borders from a table, suddenly you have a complex grid that you can use to place graphics, text, even Java applets, Flash objects, or video files. You've got a way to lay out a design. Suddenly, the very foundation of Web pages is relying on HTML elements that were never intended to perform the duties that they have performed for years, and will probably perform for some years to come.

Similarly, presentation of type on a page became an issue as more designers came to the Web. You had very few options before the font tag. You could rely on the default, or you could use a tag that forced a monospaced font, such as pre or tt:

<pre>This text appears in the user's default monospaced font.</pre>
<p><tt>So does this</tt>
<p>This text is in the default proportional font.

Either way, both were limited and not necessarily very elegant (see Figure 3.2).

Figure 3.2
Forcing monospaced fonts in HTML using pre and tt.

So along comes the font tag, and suddenly we've got ways to add some level of typographic presentation to our pages. Yes, it's imperfect display due to the limitations of Web typography—a visitor's machine must have that font face installed, the browser must support the tag, and so on.

But even more devastating to HTML as a formatting language is the absolute mess that font tags create. They work extremely poorly. You can't set a default font on a page with them, you must open and close them every time you want to change some attribute related to them, and you must open and close them within sections of your HTML, such as within each table cell. Begin with a nice, tight document (see Listing 3.3), and by the time you're done adding pretty fonts to a page, you've definitely doubled, possibly tripled—and maybe even quadrupled the weight of your document (see Listing 3.4). Plus, you've made it harder to read, harder to troubleshoot, and simply said, much sloppier.

Listing 3.3 A Simple HTML Page Layout, No Fonts. Weight: 1KB

<html>
<head>
  <title>King Lear: Act 2, Scene 1</title>
</head>

<body>

<h3>Edmund</h3>

<p>The duke be here to-night? The better! best!
This weaves itself perforce into my business.
My father hath set guard to take my brother;
And I have one thing, of a queasy question,
Which I must act: briefness and fortune, work!
Brother, a word; descend: brother, I say!</p>
<p>Enter EDGAR</p>

<p>My father watches: O sir, fly this place;
Intelligence is given where you are hid;
You have now the good advantage of the night:
Have you not spoken 'gainst the Duke of Cornwall?
He's coming hither: now, i' the night, i' the haste,
And Regan with him: have you nothing said
Upon his party 'gainst the Duke of Albany?
Advise yourself.</p>

</body>

</html>

Listing 3.4 The Same Layout with Fonts. Weight: 2KB

<html>
<head>
  <title>King Lear: Act 2, Scene 1</title>
</head>

<body bgcolor="#000000">

<h2><font face="arial, helvetica, sans-serif" 
color="#FFFFCC">Edmund</font></h2>

<p><font face="garamond, times, serif" size="4" color="#CCFFFF">
The duke be here to-night? The better! best!
This weaves itself perforce into my business.
My father hath set guard to take my brother;
And I have one thing, of a queasy question,
Which I must act: briefness and fortune, work!
Brother, a word; descend: brother, I say!</font></p>

<p><font face="arial, helvetica, sans-serif" color="#FFFFCC">
Enter EDGAR</font></p>

<p><font face="garamond, times, serif" size="4" color="#CCFFFF">
My father watches: O sir, fly this place;
Intelligence is given where you are hid;
You have now the good advantage of the night:
Have you not spoken 'gainst the Duke of Cornwall?
He's coming hither: now, i' the night, i' the haste,
And Regan with him: have you nothing said
Upon his party 'gainst the Duke of Albany?
Advise yourself.</font></p>

</body>

</html>

Of course, by HTML 4.0, it became very apparent that there was a serious need to remove document presentation from document structure to bring back some rigor to HTML. So, under this concept, your basic HTML document would begin limiting to document formatting elements such as is seen in Listing 3.3. It would then incorporate a stylesheet externally (see Listing 3.5), with a link to that sheet found in the head of the document.

Listing 3.5 Style Sheets Allow for the Addition of Style, Separate from the Document's Formatting Elements

H2 {
font-family : arial, helvetica, sans-serif;
  color : #FFFFCC;
}
p.1 {
  font-family : arial, helvetica, sans-serif;
}
p.2 {
  font-family : arial, helvetica, sans-serif;
  font-size : 14pt;
  color : #CCFFFF;

}

However, browser support for style sheets, which are the most lucid and useful answer to presentation and placement concerns, are to this day poorly supported across browsers and platforms, making them at best quite challenging to use in real-world situations.

The irony here is that style sheets are not a new idea. They've been around since the early desktop publishing days, when the same issues came to the forefront in DTP software. Once again, the rapid development of Web design forced HTML into corners it was too willing yet linguistically less than capable of controlling. In many ways, this is why we have the problems we have today when trying to gain consistency with layouts, fonts, and other presentational concerns.

Difficulties Across Platforms and Browsers

So, the demand for better visual sites altered HTML as a language. And, as a result, the bane of the Web designer's existence has become trying to figure out ways to make HTML work as a tool of design across platforms.

What we create for the Windows environment is always going to be somewhat different from what is created for the Mac environment, or Linux environment, and so on.

Platform-wise, there is little we can control as designers because hardware and software issues influence the way that user agent software—in most instances the Web browser—read our documents.

But to make our sites cross-platform, cross-browser compliant, we have to work extra hard. Imagine if browser developers adhered to certain standards with the way they wrote their software and the way that software in turn displayed our code? Our lives would be made much more simple. But browser developers have had their own agenda, and it's done very little to help us. As a result, Web designers in contemporary times typically have to

  • Test their work on numerous platforms.

  • Test their work in numerous browser types.

  • Use legacy as well as current browsers in testing.

  • Rely on authoritative charts and materials to compare and contrast what works and what doesn't work in a given platform/browser environment.

  • Learn stress-management techniques to cope with the extra long hours spent trying to make a great design be interoperable.

My bottom line here is that it's simply not enough to make the author completely responsible for code compliance! Browser manufacturers have as much—if not more—responsibility when it comes to both the messes of the past and the fixes of the future.


Note - A coalition of Web developers and Web users make up the Web Standards Project, which exists to call browser developers on the floor and demand they pay attention to standards. You can visit the Web Standards Project at http://www.webstandards.org/.


Poor Habits Extending to Software

One of the most frustrating issues surrounding HTML is how the bad habits and non-standard methods of its evolutionary being have traveled into HTML editors. This is especially disconcerting in today's Web production environment, where many authors and designers are being asked to use specific editors (especially visual editors) to do a job. And, given the wealth of collaborative tools and production environments that exist in visual editors, it makes sense in many cases to do this.

It becomes imperative that people understand the limitations of the software products being used. What's more, knowing the standard methods of code can totally empower you as an individual to troubleshoot problem code, refine code, reduce code overhead, and bring generated code up to standards.

Some of the major concerns in primary visual editors that I'm concerned about are defined in Table 3.1.

Table 3.1 General Common Markup Problems Associated with Popular Visual Editing Software

Product

Problem

Adobe GoLive

Introduction of proprietary code, extra code, extraneous code, complicated, unnecessary table structures, no support for XHTML 1.0.

Macromedia Dreamweaver

Some extraneous code problems, complex table structures, no current direct support for XHTML 1.0.

Microsoft FrontPage

No accommodation for hands-on coding in versions prior to 2000, introduction of own and often extraneous code, table structure problems, symmetry problems, no direct support for XHTML 1.0


In Figure 3.3, I created a very simple design and then laid it out using each of these programs. Listing 3.6 shows my results in Adobe GoLive; Listing 3.7 in Macromedia Dreamweaver; and 3.8 in Microsoft FrontPage.

Figure 3.3
A prototype of the look I was after.

Listing 3.6 Simple Layout as Coded in Adobe GoLive. Note Proprietary Code and Extraneous Markup (Boldface Type).

<html>

  <head>
    <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    <meta name="generator" content="Adobe GoLive 4">
    <title>Welcome to Adobe GoLive 4</title>
  </head>

  <body>
  <table cool width="586" height="317" border="0" cellpadding="0" 
  cellspacing="0" gridx="16" showgridx usegridx gridy="16" 
showgridy usegridy>
    <tr height="1" cntrlrow>
      <td width="1" height="1"></td>
      <td width="16" height="1">
      <spacer type="block" width="16" height="1"></td>
      <td width="569" height="1">
      <spacer type="block" width="569" height="1"></td>
    </tr>
    <tr height="16">
      <td width="1" height="16">
      <spacer type="block" width="1" height="16"></td>
      <td width="16" height="16"></td>
      <td width="569" height="16"></td>
    </tr>
    <tr height="300">
      <td width="1" height="300">
      <spacer type="block" width="1" height="300"></td>
      <td width="16" height="300"></td>
      <td width="569" height="300" colspan="1" 
      rowspan="1" valign="top" align="left" 
pos="16">
        <table border="0" cellpadding="0" cellspacing="0" width="510">
          <tr>
            <td width="195"><img height="300" width="195"
            src="king.gif" border="0" alt="King Lear"></td>
            <td width="311">
              <table cool width="317" height="248" border="0" 
              cellpadding="0" cellspacing="0" 
              gridx="16" showgridx usegridx gridy="16" 
showgridy usegridy>
                <tr height="1" cntrlrow>
                  <td width="1" height="1"></td>
                  <td width="32" height="1">
                  < spacer type="block"
                  width="32" height="1"></td>
                  <td width="256" height="1">
                  < spacer type="block"
                  width="256" height="1"></td>
                  <td width="28" height="1">
                  <spacer type="block"
                  width="28" height="1"></td>
                </tr>
                <tr height="16">
                  <td width="1" height="16">
                  <spacer type="block"
                  width="1" height="16"></td>
                  <td width="32" height="16"></td>
                  <td width="256" height="16"></td>
                  <td width="28" height="16"></td>
                </tr>
                <tr height="231">
                  <td width="1" height="231">
                  <spacer type="block"
                  width="1" height="231"></td>
                  <td width="32" height="231"></td>
                  <td width="256" height="231" colspan="1"
                  rowspan="1" valign="top" 
                  align="left" 
                  xpos="32" content csheight="44">
                    <center>
                      <font size="6" face="Arial,
                      Helvetica,Geneva,Swiss,
                      SunSans-Regular">
                      <b>King Lear</b></font> </center>
                  </td>
                  <td width="28" height="231"></td>
                </tr>
                </table>
            </td>
            <td></td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</body>
</html>

Listing 3.7 Simple Layout as Coded in Macromedia Dreamweaver. Much Cleaner, but Still Some Code Problems, Such as the Center div Within the Second Table Cell.

<html>
<head>
<title>Dreamweaver Sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">
<table width="75%" border="0" cellspacing="5" cellpadding="0" align="left">
 <tr>
  <td width="50%"><img src="king.gif" width="195" height="300"></td>
  <td width="50%" align="top"> 
   <div align="center"><font face="Arial, Helvetica, sans-serif" size="6">
   <b>King
    Lear</b></font></div>
  </td>
 </tr>
</table>
</body>
</html>

Listing 3.8 Simple Layout as Coded in Microsoft FrontPage. Also Cleaner Than Adobe GoLive, but Look at the Unnecessary Use of a Paragraph Within a Table Cell.

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>

<body>

<div align="left">
 <table border="0" width="47%" cellpadding="0" cellspacing="0">
  <tr>
   <td width="23%"><img border="0" src="king.gif" width="195" height="300">
   </td>
   <td width="77%">
    <p align="center"><b><font face="Arial" size="6">King Lear</font>
    </b></td>
  </tr>
 </table>
</div>

</body>


</html>

Most visual editors have table problems when tables start becoming complex. It's no wonder, since tables are being forced by the software to accommodate the designer's layout. Software is not as sophisticated in its methodology as a human being who has studied the ins-and outs of markup. This is one of the many reasons I advocate learning how to do things by hand, even if you use a visual editor in your work.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020