Open In App

How to Set the Border Thickness of a Table in HTML ?

To set the border thickness of a table in HTML, you use the “border” attribute within the <table> tag. This attribute specifies the width of the borders around the table and its cells. The value of the “border” attribute represents the thickness of the border in pixels (px).

Syntax

<table border="value">
<!-- Table content: rows and cells -->
</table>
Key Point Description
Border Thickness The value of the “border” attribute determines the thickness of the table’s border and cell borders.
Default Value If the “border” attribute is omitted or set to “0”, the table will have no borders by default.
Border Collapse The border thickness applies to both the outer border of the table and the borders between individual cells.
Styling For more advanced styling options, such as custom border styles or colors, CSS should be used in conjunction with HTML attributes.

Features

<table border="0">
<!-- Table content: rows and cells -->
</table>
<style>
table {
border: 2px solid black;
}
</style>
<table>
<!-- Table content: rows and cells -->
</table>
Article Tags :