W3Schools HTML Table Border: Complete Guide to Master Cell Borders and Styling

Logan Jul 13, 2026

Diving into HTML table styling, one of the first CSS properties you'll likely encounter is 'border'. This attribute allows you to add, remove, or customize the borders around your table cells. W3Schools, a renowned learning platform for web development, offers a comprehensive guide to understanding and implementing this property. Let's explore 'border' in HTML tables with the help of W3Schools.

Responsive HTML Table With Rounded Corners
Responsive HTML Table With Rounded Corners

W3Schools introduces the 'border' property by explaining its simplest usage. By default, a table in HTML is displayed without any borders. If you want to add borders around your table, you can do so by using the 'border' attribute directly in your HTML. W3Schools demonstrates this with a simple example:

a diagram showing the different types of sound waves
a diagram showing the different types of sound waves

Understanding the 'border' Attribute in HTML

W3Schools first explains that the 'border' attribute is used to set the thickness of the border around a table. It accepts pixel values as arguments. For instance, 'border="1"' will set a thin border around the table, while 'border="5"' will make the border noticeably thicker.

W3Schools.com
W3Schools.com

W3Schools then discusses the 'border-collapse' property, which controls whether the borders of neighboring cells should be collapsed into a single border. Setting 'border-collapse="collapse"' will combine the borders of adjacent cells, providing a continuous look. Their tutorial includes a visual comparison to illustrate this effect.

Setting Borders with the 'border' Attribute

🧾 How to Create Tables in HTML
🧾 How to Create Tables in HTML

W3Schools shows how to use the 'border' attribute to style a single table's border. However, it's important to note that this attribute is deprecated in HTML5 and replaced by the 'style' attribute and CSS for styling. W3Schools quickly demonstrates this transition:

<table border="1">
</table>

becomes

<table>
  <style>
    table, td {border: 1px solid black;}
  </style>
</table>

Using CSS for Better Control

the table borders for different types of text
the table borders for different types of text

W3Schools then emphasizes the superiority of using CSS for table styling. With CSS, you can have more control over the border's appearance, such as setting different colors or styles for different rows, columns, or cells. They provide a detailed explanation of how to achieve this, along with an interactive example.

To illustrate, here's how you might style a table's borders using CSS:

<style>
  table {
    border-collapse: collapse;
  }
  th, td {
    border: 1px solid black;
    padding: 15px;
  }
</style>
<table>
  <tr>
    <th>Header</th>
    <td>Data</td>
  </tr>
</table>

Style Individual Borders with CSS

W3Schools.com
W3Schools.com

Furthermore, W3Schools delves into how to style individual borders of a table using CSS. They explain how to target cell, row, or column borders individually, providing detailed examples and visual demonstrations.

For instance, to apply different styles to a cell's borders, you might use the 'border-left', 'border-right', 'border-top', and 'border-bottom' properties:

the table borders for different types of text
the table borders for different types of text
css border
css border
How To Style Table Borders In CSS HTML
How To Style Table Borders In CSS HTML
HTML Table Styler 📅 CSS Generator
HTML Table Styler 📅 CSS Generator
30 Best Free HTML/CSS Table Templates Templates 2026 - Colorlib
30 Best Free HTML/CSS Table Templates Templates 2026 - Colorlib
Responsive Table HTML and CSS Only
Responsive Table HTML and CSS Only
CSS border styles
CSS border styles
40 Best CSS Table Templates For Creating Appealing Tables 2026
40 Best CSS Table Templates For Creating Appealing Tables 2026
Responsive Table V1 - Free HTML/CSS Table Template 2026 - Colorlib
Responsive Table V1 - Free HTML/CSS Table Template 2026 - Colorlib
CSSのborderプロパティ:枠線の設定とデザインの基本
CSSのborderプロパティ:枠線の設定とデザインの基本
A Detailed Guide to HTML Tables | Simplilearn
A Detailed Guide to HTML Tables | Simplilearn
CSS Table Layout
CSS Table Layout
HTML Table
HTML Table
Welcome to SiteRaw
Welcome to SiteRaw
Computer Programming A4 Border Design
Computer Programming A4 Border Design
Responsive Table V2 - Free HTML/CSS Table Template 2026 - Colorlib
Responsive Table V2 - Free HTML/CSS Table Template 2026 - Colorlib
Learn CSS Border Shorthand in 16 Seconds
Learn CSS Border Shorthand in 16 Seconds
CSS Border - Learn All the Basics!
CSS Border - Learn All the Basics!
the css borderr radus menu
the css borderr radus menu
an image of a table with numbers and symbols on the top right hand corner that says tables
an image of a table with numbers and symbols on the top right hand corner that says tables

Styling Individual Borders

W3Schools shows how to create different border styles for different cell borders. For example, to create a cell with a thick left border and a thin right border:

<td style="border-left: 3px solid black; border-right: 1px solid black;"></td>

W3Schools goes on to explain how to target entire rows or columns, providing code snippets for reference.

Applying Border Styles to Entire Rows or Columns

W3Schools demonstrates how to style an entire row's borders. For example, to style a row's borders with a solid red color and a width of 2 pixels:

<tr style="border: 2px solid red;"></tr>

Similarly, they show how to target entire columns using 'col' elements.

In the realm of HTML table styling, the 'border' attribute and its CSS counterparts offer a wealth of possibilities. W3Schools, with their interactive examples and clear explanations, provides an excellent starting point for any web developer looking to master this aspect of HTML. So, dive into their tutorials and start exploring the world of table borders!