HOWTO · HTML

How to Remove Borders From HTML Table

This article introduces how to remove borders from HTML Table

On this page

To remove visible borders from an HTML table, set the CSS border property to none on the table and cells that show a line. Use border-collapse: collapse when you want adjoining cell borders to share one line; that property combines borders rather than removing them. This distinction is useful when arranging images or other content inside cells: collapse changes how adjoining borders meet, while border: none removes the rendered borders of the selected elements.

Use border-collapse: collapse to Combine Adjacent Table Cell Borders in HTML

The CSS border-collapse property controls whether a table uses the separated or collapsed border model. With collapse, adjoining cell borders are combined, so two cells do not draw separate lines along their shared edge. Existing borders can still be visible around the outside of the table and around its cells; this declaration does not remove them. It also is not a way to set spacing to zero. In the separated model, border-spacing controls the gap between cell borders. The collapsed model combines adjoining borders instead, so changing border-spacing is not the fix for visible lines in that model.

This small HTML example has two cells with borders. The table rule combines the lines where those cells meet, while the cell rule keeps the lines visible:

const example = `<style>
table { border-collapse: collapse; }
td { border: 1px solid #555; padding: 0.5rem; }
</style>
<table>
  <tr><td>Image</td><td>Caption</td></tr>
</table>`;
console.log(example);
<style>
table { border-collapse: collapse; }
td { border: 1px solid #555; padding: 0.5rem; }
</style>
<table>
  <tr><td>Image</td><td>Caption</td></tr>
</table>

Replace the sample cell text with your own content, including an image element if the cells hold images. The CSS works with ordinary <td> and <th> cells and does not depend on an image service. The padding declaration adds space inside each cell; it does not control the gap between separate cell borders. If you want a grid with shared lines, retain the cell border and use collapse. If you want no lines, remove the applicable border declarations as described below.

Set the CSS border Property to none to Remove Border From a Table in HTML

To hide borders, set border: none on the table and each kind of cell whose borders should disappear. A rule using table, th, td targets the table, header cells, and data cells together. If the table outline is already absent and only cell lines remain, th, td can target just those cells. The selector determines which elements receive the declaration; the CSS cascade determines which matching declaration wins. A more specific rule can override a general selector, and when specificity is equal, a later declaration wins.

The border property is shorthand for border-width, border-style, and border-color. Setting it to none removes the rendered border from the selected elements, but it does not remove cell padding or content. For example, a stylesheet can use table, th, td { border: none; } when all three element types should have no visible border. Add border-collapse: collapse only if you also want the table to use the collapsed model; it does not replace border: none.

If a line remains, inspect which element draws it. A border on the table needs a rule that matches the table; a border on a header or data cell needs a rule that matches th or td. Then check whether another stylesheet rule overrides your declaration. This keeps the fix specific to the elements that actually have borders and avoids changing unrelated table spacing or content.