HTML Tables Tutorial With Notepad
HTML Tables Tutorial With Notepad
Terry Koluch
Dan Solarek
HTML Tags
Tables are denoted by a set of <table> and
</table> tags
Tables can be nested to any level
When nested, you place a second table
within a table cell
Default is for tables to display borders. You
can use hidden tables (i.e., tables without
borders) to control element alignment without
the information appearing to be in a table
Captions
Use the <caption>information</caption> tag
set to add a caption to a table
If used, must appear directly after the
opening <table> tag
Default placement is centered above the
table, but can also use align=position
attribute as follows
Row Groups
Can classify a tables rows into row groups to
specify their purpose
Types of row groups
A Simple Example
Table Borders
As mentioned on previous slides, default browser
behavior is to not display table borders. Here is an
example of a hidden table. Use View/Source to see
the HTML. Either omit the border attribute or set it
equal to 0
Use border=value attribute to specify border size
where value is width in pixels
Use the Cascading Style Sheet (CSS) inline style
attribute to specify the background color of a table.
We will cover CSS technology later in the course.
For now, use style=background-color: color (note:
default is two shades of gray to create a 3dimensional effect) where color is either an HTML
color or a hexadecimal color code
Table Frames
By default, a table border surrounds the entire table
and each cell within the table
Use the frame=value attribute to specify which
sides of a table will have borders where value can be
Table Rules
Use the rules=value attribute to
control how gridlines are drawn within a
table where value can be
all around cells
cols around columns
groups around row groups
none no rules
rows around rows
Horizontal Alignment
Use the align=position attribute to specify horizontal
alignment
Position can be
Vertical Alignment
Use the valign=position attribute to specify
vertical alignment
position can be
top
middle - default
bottom
baseline - The baseline is an imaginary line upon
which rests all letters in a line of text. baseline
sets the row so that all cells share the same
baseline. Most of the time this has the same effect
as bottom, but if the fonts are different sizes, then
baseline will result in a better appearance
Table Alignment
Use the float:position style to align a table
with either the left or right margin of a page
and then allow the text to flow around the
table. As you probably surmised, position can
be either left or right
If you do this, typically a good idea to specify
the margins style to prevent text from
crowding too closely. Margins specified as
margin: top bottom left right where each of
the 4 are specified in pixels