Tables, Forms, and CSS




CS174

Chris Pollett

Sep 9, 2020

Outline

Introduction to Tables

Today, we continue our discussion of HTML and XHTML 5 by looking at the table and form tags.

Example:

Below is an example table we discussed last week:

<style>
table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}
</style>
<table>
    <caption>grade table</caption>
    <tr><td></td><th>Item</th><th>Value</th></tr>
    <tr><th>1.</th><td>Homeworks</td><td>50%</td></tr>
    <tr><th>2.</th><td>Exams</td><td>50%</td></tr>
</table>
grade table
ItemValue
1.Homeworks50%
2.Exams50%

Note: Although in this example we used the <style> tag immediately before the table, for this to be valid html, all style tags would need to be in the <head> of the document.

More on Tables

You can make table headings or table data span more than one column or more than one row using colspan, rowspan:

<tr><th colspan="3">heading</th></tr>

Here is an example where we have two levels of headings at the top of a table:

<tr><th colspan="2">heading</th></tr>
<tr><th>subhead1</th><th>subhead2</th></tr>
<tr><td>1</td><td>2</td></tr>

An Accessibility Interlude

Tables and Accessibility

Controlling width

Still More on Tables

Cellpadding, cellspacing

In-Class Exercise

Forms

Possible methods

Labels and Controls

select tags

<textarea>

Stylesheets