Within the table element
are table row elements (
|
), and nested within those are table cell elements
(
| ). The actual content is placed inside the td elements. Therefore, a simple table
with two rows containing two cells each is created like this:
| Cell one | Cell two |
| Cell three | Cell four |
Adding a border
You can place a border around table cells by using the border attribute and setting its
value to 1 or greater. The adjacent example shows how this looks in a web browser.
HTML borders for tables have a kind of 3D effect and tend to look clunky and oldfashioned.
If you want to add a border to a table, this is best done in CSS.
Cell spacing and cell padding
In addition to amending the border size, it??™s possible to change the amount of padding
within a table??™s cells, as well as the spacing between all the cells in a table. This is done with
the cellpadding and cellspacing attributes, respectively. In the rather extreme example
that follows, cellpadding is set to 20, cellspacing to 40, and border to 5, so that each
can be differentiated with ease (see the subsequent screenshot). As you can see,
cellspacing not only affects the spacing between the cells, but also the distance between
Always ensure that you include all end tags when working with tables. If you began
working with HTML in the mid-1990s, you may have learned that it??™s OK to omit the
odd end tag from tables or table cells.
Pages:
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329