Browser-dependent HTML
By Randal L. Schwartz
I have always been a strong advocate of browser-independent, standard HTML as the universal medium of the Web. However, as friend and Web designer Devin Ben-Hur points out, not all browsers comply with the current standards, a situation that can stifle communications and confuse the reader. Devin suggested that I write a column about handling HTML that adapts itself to the browser dynamically. I thought that sounded like a neat idea, so here it is, and thanks to Devin (dbenhur@emarket.com) for this month's topic.
I decided to approach browser discrepancies using the table problem. Most modern browsers handle tables just fine, but twoýLynx and the W3-mode of GNU Emacsýdo not. So, to present data in a universal fashion, it must be both table-encoded for most of the world and generated as a pseudotable (using <PRE>) for browsers that can't handle tables.
One possible solution was for a filter to read an HTML-encoded table, reverse-engineer it into its rows and columns, and then perform some layout function to generate equivalent <PRE> text. This can get pretty messy, and would certainly have had me writing a hefty chunk of code. I'm too lazy for that, so I took a different approach.
Namely, I decided to generate either an HTML table or a <PRE> text area from a plain text file with tab-separated columns and newline-delimited rows. This common, unambiguous format can be parsed rapidly, and translates nicely into both <PRE> text and full-blown <TABLE> text.