HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
The look of an HTML table can be greatly improved with CSS
To specify table borders in CSS, use the border
property.
The example below specifies a solid border for <table>, <th>, and <td> elements:
Firstname | Lastname |
---|---|
Peter | Griffin |
Lois | Griffin |
table, th, td {
border: 1px solid;
}
The table above might seem small in some cases. If you need a table that should span the entire screen (full-width), add width: 100%
to the
<table> element:
Firstname | Lastname |
---|---|
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 border-collapse
property sets whether the table borders
should be collapsed into a single border:
Firstname | Lastname |
---|---|
Peter | Griffin |
Lois | Griffin |
table
{
border-collapse: collapse;
}
If you only want a border around the table, only specify the border
property for
<table>:
Firstname | Lastname |
---|---|
Peter | Griffin |
Lois | Griffin |
table
{
border: 1px solid;
}