home > real world > web resource > web source codes >
To give a table a border you don't have to work with nested tables. First define the style of the border like this:
<style> .mytableborder { border-width: 1px; border-style: solid; border-color: #CCCCCC; } </style>
You put this style declaration either in an external stylesheet or in the <head> section and apply it to the table as follows:
<table class="mytableborder">
<tr>
<td>Content text and more content</td>
</tr>
</table>
That should give you a thin grey border around this table. Here it is:
Content text and more content |
You can apply this style only to a single cell of the table:
<table>
<tr>
<td class="mytableborder">Content text</td> <td>and more content</td>
</tr>
<tr>
<td>Content text</td> <td class="mytableborder">and more content</td>
</tr>
</table>
Here it is:
Content text | and more content | Content text | and more content |
...or to a paragraph (the following is not a table):
<p class="mytableborder">Content text and more content</p>
Here it is:
Content text and more content
...or to a word:
<p>Content <span class="mytableborder">text</span> and more content</p>
Here it is:
Content text and more content
|