Module W24g

Tables and Graphics


Overview
It's All About Control

to Top
to Top

The ultimate quest for control over space on the Web involves using tables to place images in creative and original ways. Some of the challanges we run into include...

  • Avoiding unwanted space around images in nested tables;
  • Creating invisible and visible separation between elements in a Web page;
  • Using gutters, shims, spacers, and margins;
  • Using tables and shims to create precisely sized Web page elements;
  • Using tables and images to create the appearance of curved and non-rectangular components.
  • Overcoming differences in the way browsers render images in tables;

These are the topics to explore and experiment with in this module.

 

Essential Terms

to Top
to Top

In addition to the HTML terms and concepts, design borrows words and ideas from printing and carpentry that we need to know:

  • Gutter: Vertical white-space between columns of text and/or images.
  • Shim: Small invisible image that serves as a wedge to force browsers to provide a certain minimum amount of space, either vertically or horizontally.
  • Spacer: Any element used to create space between other elements.
  • Margin: Empty space around the edges of elements, especially of pages.

Size Control Tools
Creating Space

to Top
to Top

Creating space between elements on Web pages can be done in several ways. The following involve using tables:

  • Adding empty columns or rows of tables;
  • Inserting new, empty tables to control width;
  • Inserting colored rows, cells, or tables to produce lines of precise thickness;
  • Inserting decorative separator images;
  • Inserting "shims" - invisible images with precise width and height specifications.

Effects and Rendering
Curved and Non-Rectangular Components

to Top
to Top

Nobody likes feeling "boxed in", and that certainly includes Web designers. Techniques for avoiding a "boxy" appearance usually involve creating images with curved edges on transparent backgrounds. It's also possible to create non-rectangular effects by creating non-rectangular images, again with transparent backgrounds - and slicing them along rectangular lines so they can be distributed artistically in tables.

Example: Curved Edges

One popular non-rectangular effect is the "tab", designed to look like the curved tab on a file folder. Here's an image created to look like a tab. It was created on a transparent background and saved as a GIF:

Tab Illustration, aqua background
Tab Illustration, light blue background
Tab Illustration, dark blue background

The the image - like all images - is rectangular, the transparent parts give it the impression of being rounded. The same image is shown against three background colors to illustrate that its background is transparent.

Tabs are usually used as menu headers. Here's a brief illustration of how a menu would look dropped down under this tab. To keep the example brief, we're representing the whole menu with only one item, and it doesn't illustrate the code required to make the menu "drop down" from the tab.

Browser View
Opera Rendering
Code View

 


<tr valign="bottom">
<!-- No border for image -->
<td><img alt="About" border="0" height="29" src="w24g_f01.gif" width="133" /></td>
</tr>
<!-- This row for first menu item, aligned to stay with image -->

<tr valign="top">
<td>
<!-- This table produces 1-pixel border -->
<table bgcolor="#ffcc00" width="133" cellpadding="1" cellspacing="0" border="0">
<tr>
<td width="100%">
<!-- This table holds top menu item -->
<table bgcolor="#ffffff" border="0" cellpadding="4" cellspacing="0" width="100%">
<tr>
<td bgcolor="#ffffff" valign="top" width="100%" align="center">
Location
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- Add more rows with double tables here for more menu items -->
</table>

Example: Triangular Logo

Triangular logo exampleSuppose you are given this logo to put in a page for a client.

How can you make a large enough rendition of it without wasting space on the Web page?

Notice how the space on the lower right side of the logo remains blank, even though the background shows through. That's because the image is rectangular, even though it appears to be a triangle.

The solution is to divide the image into four smaller rectangles, each of which can be put into a separate table. That will allow most of the unused area to be put to good use.

Slicing images is relatively easy with tools like Macromedia Fireworks and Adobe ImageReady. I used Fireworks for this example, and threw away the empty lower right quarter of the image. Instead, I put in some lines of text as headings for the page.

If I had intended to make a real page I would have extended the table to have more rows and columns, and put partial images in the transparent parts of the upper right and lower left quadrants as well.

 

Code View Browser View
<table border="0" cellpadding="0" cellspacing="0" 
width="200">
<tr>
<td><img src="w24g_f07a.gif" width="97" height="101"
border="0" alt="Upper left"></td>
<td><img src="w24g_f07b.gif" width="103" height="101"
border="0" alt="Upper right"></td>
<td><img src="shim.gif" width="1" height="101"
border="0" alt=""></td>
</tr>
<tr>
<td><img src="w24g_f07c.gif" width="97" height="99"
border="0" alt="Lower left"></td>
<td><h6>Welcome to</h6>
<h5>Pethahiah Properites</h5></td>
<td><img src="shim.gif" width="1" height="99"
border="0" alt=""></td>
</tr>
</table></td>
Upper left Upper right
Lower left
Welcome to
Pethahiah Properites

Avoiding Unwanted Space

to Top

to Top

It's important to make your code easy to read, and one of the best ways to do that is to put plenty of space - both horizontal and vertical - around elements of your code. However, spaces and lines in your code can cause problems in certain circumstances and in some browsers.

In this example, we're put our image tag on a separate line (in bold). The screen shots show the effect in three different browsers:

<table width="133" cellpadding="0" cellspacing="0" border="0">
<tr valign="bottom">
<td>
<img alt="About" border="0" height="29" src="w24g_f01.gif" width="133" />
</td>

</tr>
<tr valign="top">
<td>
<table bgcolor="#ffcc00" width="133" cellpadding="1" cellspacing="0" border="0">
<tr>
<td width="100%">
<table bgcolor="#ffffff" border="0" cellpadding="4" cellspacing="0" width="100%">
<tr>
<td bgcolor="#ffffff" valign="top" width="100%" align="center">
Location
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>

Opera Rendering

Opera 6.0 Rendering:
Looks as intended

 

Netscape Rendering

Netscape 4.7 Rendering:
gap appears between graphic and menu

 

Internet Explorer Rendering

Internet Explorer 6.0 Rendering:
also has a gap

The intention was to have the menu item(s) appear as a part of the tab image. Although one browser renders it as intended, the others shown here introduce a gap, which is the result of the whitespace around the image tag. The solution is to remove the whitespace, restoring the code to the way it was in the previous example.

Overcoming Browser Difference

to Top

to Top

Overcoming differences in the way browsers render images in tables...


to Top About This Document
Audience

to Top

This exercise is for people who are familiar with the technique of creating nested tables with widths set in various ways, and are ready to put that technique into practice. For background, see modules W24c, W24d, and W24f.

 

Objectives

On successful completion of this module, you will be able to:

  1. Explain how to avoid unwanted space around images in nested tables;
  2. Discuss differences in browser rendition of images within tables;
  3. Explain how to create invisible and visible separation between elements in a Web page;
  4. Define the terms "gutter", "shim", "spacer", and "margin" in the context of Web design;
  5. Explain how to use tables and shims to create precisely sized Web page elements;
  6. Explain how to use tables and images to create the appearance of curved and non-rectangular components.
Module W24g: Tables and Graphics

This document is part of a modular instruction series in Computer Instruction. For more information, see the overview or the list of modules in this series, W: World Wide Web. This document has been used in the following classes: INP 270 .
History
Original: 11 February 2003
Last modification: Monday, 31-Aug-2009 11:48:06 EDT
Copyright
Copyright © 2003, Laurence J. Krieg, Washtenaw Community College
Instructors: You may point to this file in your Web-based materials; however, its location may change without notice.
Students: You are welcome to make a copy for your personal use.
All other uses: Please contact the author, Laurence J. Krieg, for permission: krieg@ieee.org.