Back to the index| Previous | Next
Competences: To insert a table in the web page.
Contents: The tags table, tr,td and their style elements
Code | Output | Notes | ||||
<table> <tr><td>A1</td><td>A2</td></tr> <tr><td>B1</td><td>B2</td></tr> </table> |
|
Table 2*2 (2 rows, 2 columns) |
You can use the style property border with the td selector if you want to add a border to each cell, with tr if you want to add a border to each row or with table if you want to add a border to the whole table.
The border values are the width (in pixels), the type (solid, dotted, dashed ..) and the colour.
You must insert all the properties in the style tag in the head section.
Here there are some examples:
Css code | Output | Codice css | Output |
td {border: 2px dotted red} | A1 | td {border: 1px solid bleu} | B1 |
td {border: 1px dashed green} | C1 | td {border: 2px solid brown} | D1 |
td {border: 2px solid brown} | E1 | td {border: 2px dashed violet} | F1 |
The padding property defines the space between the bord and the content of the cell.
Css code | Output | |
td { border: 1px solid blue; padding: 5x} | A1 | A2 |
td { border: 1px solid brown; padding: 30px} | B1 | B2 |
You can add the background-color property to the table elements, as the other selectors.
Css code | Output | ||||
table {background-color:yellow;} td {padding: 30px; border: 1px solid brown} |
|
Code | Output | ||||
<table> <tr> <td><img src="image/album1.jpg" /></td> <td><img src="image/album2.jpg" /></td> </tr> <tr> <td><img src="image/album3.jpg" /></td> <td><img src="image/album4.jpg" /></td> </tr> </table> |
|
<html> <head> <style> .... table {border:...;background-color:...; } td {border: ...; padding: ...; } </style> </head> <body> .......... <table> <tr> <td> insert something here! (Text, images, links!)</td> <td> insert something here!</td> </tr> <table> </body> </html>