[WEB4LIB] As if lousy HTML editors weren't bad enough...

Thomas Dowling tdowling at ohiolink.edu
Thu Nov 5 13:25:34 EST 1998


>
>"Although HTML purists (and validation programs) may object, most
>Web browsers can correctly interpret pages without some elements,
>such as quote marks around tag attributes (like <IMAGE
>HEIGHT="50">) and tags added by some HTML editors (like
><NATURALSIZEFLAG>)." - Jeff Carlson <jeffc at tidbits.com>

As a purist-poseur (I think a Real Purist would have the HTML declaration
memorized), I will point out that quote marks around attribute values are
unnecessary if the value contains only letters, numbers, hyphens, and
periods.

>
>One program will even remove such "superfluous" closing tags as </HEAD>
>and </HTML>. Thanks. I could use the help.
>
>Has anyone seen the effects of this yet? Or, (horrors) used them? Anyone
>care to make a defense of them before "HTML purist" Thomas Dowling guns
>you down in a blaze of validation errors? See
>http://www.tidbits.com/tb-issues/TidBITS-453.html#lnk2 for the whole, sad
>story. As if to add insult to injury, you have to pony up $70-80 for
these
>programs, all for the privilege of having the worst HTML on the block. Go
>figure.


Ah, but </HEAD> and </HTML> (and even <HTML>, <HEAD>, and <BODY>) really
are optional, just like </TD> and </TR>.  Just don't complain if a
non-compliant browser misbehaves when you leave them out.

[How much can you leave out?  The following line is a complete HTML file,
validated against HTML 4.0 Transitional:

  <title>Test</title>This completes our test.

]

As a counterpoint to this thoroughly brain-dead sort of utility (hint:
cropping a GIF by a few pixels will result in more savings than removing
quotes from attributes!), I recommend Dave Raggett's tidy utility
<URL:http://www.w3.org/People/Raggett/tidy/>.  It's can fix some bad
markup, though of course it isn't a replacement for writing good markup in
the first place.  By itself, it can almost turn Microsoft Word's fevered
idea of HTML into valid markup.

Below is an example of tidy turning a small garbage file into presentable
HTML.

By the way, I don't gun anything down.


Thomas Dowling
OhioLINK - Ohio Library and Information Network
tdowling at ohiolink.edu

=========
% tidy -c -f errors.out bad.html > good.html
% cat bad.html
<title>Sample Markup</title>
<p>
This is a example of an HTML file.

<CENTER>
<table width=50%>
<tr><td colspan=2>Stop & Go
<tr><Td valign=top><img src=greenbutton.gif alt='Green Button'>
<Td valign=top><img src=redbutton.gif>
<tr><td><b><i>Go</b></i><td><b><i>Stop</b></i></table>
</center>

<p>
The End.


% cat good.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>Sample Markup</title>
<style>
 DIV.c1 {text-align: center}
</style>
</head>
<body>
<p>This is a example of an HTML file.</p>

<div class="c1">
<table width="50%">
<tr>
<td colspan="2">Stop &amp; Go</td>
</tr>

<tr>
<td valign="top"><img src="greenbutton.gif" alt="Green Button">
</td>
<td valign="top"><img src="redbutton.gif"></td>
</tr>

<tr>
<td><b><i>Go</i></b></td>
<td><b><i>Stop</i></b></td>
</tr>
</table>
</div>

<p>The End.</p>
</body>
</html>







More information about the Web4lib mailing list