Doc Steve
Web Coding Service

Fully Accessible Web Code, Custom Written by Hand
Specializing in html, xml, css, and U.S.§508

Web Technical Notes

[ Technical Pages Home ]

IE/NS Issues Pages

Descender Demonstrations

[ Skip Index ]
[ The Problem ] [ DTD Examples ] [ Design Considerations ]

The Problem

Netscape and Internet Explorer handle line-breaks and the spaces between lines differently. In a nutshell, the later Netscape (and successor Mozilla) always "protects" the descender, while Internet Explorer does not. This can produce radically-different looking tables.

For the unitiated, a descener is that thing in lowercase letters like "g", "j", "q", and "y" that are drawn below the baseline of the letter. In printing, some other letters are also occassionally drawn with descenders, like the lower-case letter "f" when it is drawn like "ƒ" (also used as the symbol for "function" or "florin"), and the lower-case "f" also is generally rendered with a descender in italic (i.e., f).

The problem stems from how the <img> element is defined (conceptiually) by the user agent. In-line elements assume that decenders will exist, and therefore add raise the baseline to protect for them. Block elements simply put in a space following the element, with the baseline the bottom of the block. While this can be controlled to an extent through declaring a specific style (using sytle sheets) or through the DTD used, in the absence of a recognized DTD or of a specified style the browsers' default assumptions govern, which can be -- generally -- chaotic. For DTDs, problems occur with non-standard DTDs and with XHTML DTDs; for styles, the "display" property will impact how the table is drawn.


Identifying and Fixing the Problem

The problem is when the table looks like this (this is manufactured to "break" on all browsers)

descender demonstration graphicdescender demonstration graphic
 
descender demonstration graphicdescender demonstration graphic
 
descender demonstration graphicdescender demonstration graphic
 
descender demonstration graphicdescender demonstration graphic

when what you really want looks like this (using style sheets: this should display properly on all browsers)

descender demonstration graphicdescender demonstration graphic
descender demonstration graphicdescender demonstration graphic
descender demonstration graphicdescender demonstration graphic
descender demonstration graphicdescender demonstration graphic

and this (the same)

descender demonstration graphicdescender demonstration graphic
descender demonstration graphicdescender demonstration graphic
descender demonstration graphicdescender demonstration graphic
descender demonstration graphicdescender demonstration graphic

To get the latter two working examples to render properly in all browser environments on this page (which utilizes an XHTML DTD and validates), the following code was used:

  1. For the first table:
      <style type="text/css">
         tr.decoration img {
           display: block }
      </style>
    
    and then in the table
      <tr class="img">
    
  2. and for the second table:
      <style type="text/css">
         td img.demo {
           display: block }
      </style>
    
    and then in the table
      <tr>
        <td><img class="demo" ...
    
The DTD on this page is the following:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
   PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

So this works.


Additional CSS Display Examples

These four examples demonstrate four typical values for the CSS "display" property (and these all differ radically between IE6, NS4/6/7, and Mozilla browsers):

block

<style type="text/css">
  td img.block { display:block }
</style>
descender demonstration graphicdescender demonstration graphic
descender demonstration graphicdescender demonstration graphic
descender demonstration graphicdescender demonstration graphic
descender demonstration graphicdescender demonstration graphic

inline

<style type="text/css">
  td img.inline { display:inline }
</style>
descender demonstration graphicdescender demonstration graphic
descender demonstration graphicdescender demonstration graphic
descender demonstration graphicdescender demonstration graphic
descender demonstration graphicdescender demonstration graphic

run-in

<style type="text/css">
  td img.run-in { display:run-in }
</style>
descender demonstration graphicdescender demonstration graphic
descender demonstration graphicdescender demonstration graphic
descender demonstration graphicdescender demonstration graphic
descender demonstration graphicdescender demonstration graphic

compact

<style type="text/css">
  td img.compact { display:compact }
</style>
descender demonstration graphicdescender demonstration graphic
descender demonstration graphicdescender demonstration graphic
descender demonstration graphicdescender demonstration graphic
descender demonstration graphicdescender demonstration graphic



DTD examples

Modifying each table in a page may not be practical. An alternate approach is to use a DTD that the browsers regocnizes and that triggers the desired table layout. The following examples each use a different (or no) DTD to demonstrate this probelm. Each utilizes the above graphic. The following code is used for the tables, which includes not style modifications for block display. Each example page validates as appropriate and should display properly on all IE platforms and on Netscape up to 4, but Netscape 6/7 and Mozilla will have various problems due to how the standard on descenders is interpreted:

<table border="0" cellpadding="0" cellspacing="0"
       summary="This table is a demonstration table to show how protecting below the baseline can deform presentatins">
  <tr>
    <td><img src="gifs/A.gif" width="10" height="10" alt="descender demonstration graphic" /></td>
    <td><img src="gifs/B.gif" width="10" height="10" alt="descender demonstration graphic" /></td>
  </tr>
  <tr>
    <td><img src="gifs/B.gif" width="10" height="10" alt="descender demonstration graphic" /></td>
    <td><img src="gifs/A.gif" width="10" height="10" alt="descender demonstration graphic" /></td>
  </tr>
  <tr>
    <td><img src="gifs/A.gif" width="10" height="10" alt="descender demonstration graphic" /></td>
    <td><img src="gifs/B.gif" width="10" height="10" alt="descender demonstration graphic" /></td>
  </tr>
  <tr>
    <td><img src="gifs/B.gif" width="10" height="10" alt="descender demonstration graphic" /></td>
    <td><img src="gifs/A.gif" width="10" height="10" alt="descender demonstration graphic" /></td>
  </tr>
</table>

[ Descender Demonstration with Non-Standard DTD ]
[ Descender Demonstration with No DTD ]
[ Descender Demonstration with Standard XML DTD (XHTML 1.0) ]
[ Descender Demonstration with Standard HTML DTD (HTML 4.01) ]
[ Descender Demonstration with Standard HTML DTD (HTML 3.2) ]


Design Considerations

Two methods of a fix are provided here. One fix is based on DTDs, which is actually a work-around. In Netscape's words, it gets the browser into "quirks mode" and thus by a somewhat indirect approach generates the desired display. The second fix relies on style sheets, and is the direct means of obtaining the desired display. Both need to be done on all pages. Both will produce the desired result of not exploding tables, with no adverse side effects, in all environments. The DTD approach is easier for existing pages, as it is a single simple and obvious change, and would be a rapid fix. The latter is actually the technically correct change, and while it is far more invasive, it would be routine when generating new pages.


References

Reference: Netscape, DevEdge, Images, Tables, and Mysterious Gaps


Document: http://
Revised:
TOP ]
HOME ]

Made with Cascading Style Sheets  | Valid CSS!  | Valid XHTML 1.0!  | Level Triple-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0  | Bobby WorldWide Approved AAA

Copyright © 2003 - 2004

Steve Sconfienza, Ph.D.

All Rights Reserved