This site is mobile accessible. Press the "Tap Here" button to use a smaller font-size.
Smartphone icons created by Freepik - Flaticon
The look of an HTML table can be greatly improved with CSS:
Company | Contact | Country |
---|---|---|
Alfreds Futterkiste | Maria Anders | Germany |
Berglunds snabbköp | Christina Berglund | Sweden |
Centro comercial Moctezuma | Francisco Chang | Mexico |
Ernst Handel | Roland Mendel | Austria |
Island Trading | Helen Bennett | UK |
Königlich Essen | Philip Cramer | Germany |
Laughing Bacchus Winecellars | Yoshi Tannamuri | Canada |
Magazzini Alimentari Riuniti | Giovanni Rovelli | Italy |
To specify table borders in CSS, use the border property. The example below specifies a black border for <table>, <th>, and <td> elements:
First name | Last name |
---|---|
Peter | Griffin |
Lois | Griffin |
table, th, td { border: 1px solid black; }
The table above might seem small in some cases. If you need a table that should span the entire screen (full-width), add
to the <table> element:First name | Last name |
---|---|
Peter | Griffin |
Lois | Griffin |
table { width: 100%; }
Notice that the table in the examples above have double borders. This is because both the table and the <th> and <td> elements have separate borders. To remove double borders, take a look at the example below.
The
property sets whether the table borders should be collapsed into a single border:First name | Last name |
---|---|
Peter | Griffin |
Lois | Griffin |
table { border-collapse: collapse; }
If you only want a border around the table, only specify the border property for <table>:
First name | Last name |
---|---|
Peter | Griffin |
Lois | Griffin |
table { border: 1px solid black; }