Open In App

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

Last Updated : 19 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

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

  • Setting Border Thickness: Specify the desired thickness of the table border by assigning a value to the “border” attribute:
  • No Border: If you want to remove the border from the table entirely, set the “border” attribute to “0”
<table border="0">
<!-- Table content: rows and cells -->
</table>
  • CSS Styling: For more control over the appearance of the table border, including custom styles and colors, CSS should be used
<style>
table {
border: 2px solid black;
}
</style>
<table>
<!-- Table content: rows and cells -->
</table>

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads