Home > Articles > Web Services > XML

  • Print
  • + Share This

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.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.