<html> Topic 7

Answers to quiz

 

1. One of the most important features to understand about tables is that every tag you open must be closed. Be sure to keep this in mind when you "nest" tables, put a table inside another table. One reason many web designers and editing programs indent their tags is to help keep track whether each opening tag has also been closed. The following shows the order of tags necessary to open and close a table nested inside a table:

<table> <!-- starts main table -- >
     <tr> <!-- each table must have a row, starts here --> 
        <td> <!-- each table must have cells, starts here -->
             <table> <!-- this starts the "nested" table -->
                 <tr> <!-- starts row of "nested" table -->
                     <td> <!-- starts cell of "nested" table -->
                     </td> <!-- ends cell of "nested" table -->
                 </tr> <!-- ends row of "nested" table -->
             <table> <!-- ends the "nested" table -->
        </td> <!-- <!-- ends cell of main table -->
      </tr> <!-- this ends row of main table -->
</table> <!-- this ends the main table, at last -->

2. "Height" is not an attribute for a table or table cell. You add both width and height attributes when inserting an image, but not a table. Several html editing programs will add height, but that will not get approved by the html 4.0 validation service. Using the "height" attribute can pose other problems, especially if specified in pixels. A table with a specified height of "450 pixels", for example, may look fine on your computer, but when it is displayed on someone else's monitor it may introduce surprising and unwanted space into your table.

3. The problem here is that an attribute value must be literal, in this case stated in pixels, unless it is enclosed in quotation marks. What that means is:

  • <td width=30> is acceptable because it is "literal" and means the table cell should be 30 pixels wide.

  • <td width="30"> is acceptable because it also means the table cell should be 30 pixels wide.

  • <td width="30%"> is acceptable because the attribute is enclosed in quotation marks. (This is one reason it is a useful habit to always use quotation marks for all attributes.)

  • <td width=30%> is not acceptable because it is not "literal" and not all alphabetic characters.

4. Heh, heh. This is a trick question. You can use both <br> and <p> inside a table. However, these must be inside a <td> cell </td> tag. It is often good to add a <br> at the end of each row of a table to improve its readability on text-only or pre-3.0 browsers. But to do that you must put the <br> inside a cell, not at the end of the row.

5.Some designers feel it is usually better to use percentage rather than pixel to define cell width, being careful to use the quotation marks so that <td width="xx%">. This is so that the width will resize to fit your viewer's monitor. In some cases you may want to have one cell be a width fixed in pixels, but then be sure that at least one other cell is set in percentage so that there is some flexibility in your page.

 
Readings
Resources
<head>
<p> etc.
<b> etc.
<li> etc.
<a href>
<img src>
Access
<table>
<frame>
<style>
<form>
<script>
<object>
validate

Copyright by dwang, 1999. All rights reserved.

1