Just take the css that works for all tables, and add table.bordered before all of them:

table.bordered {
   border-collapse: collapse;
}
table.bordered td,  table.bordered th {
   border: 1px solid orange;
}
<table class="bordered">
    <tr> <td> ABC </td> <td> DEF </td> </tr> 
    <tr> <td> HIJ </td> <td> JLK </td> </tr>
</table>

<table>
    <tr> <td> ABC </td> <td> DEF </td> </tr> 
    <tr> <td> HIJ </td> <td> JLK </td> </tr>
</table>
Answer from dave on Stack Overflow
🌐
W3Schools
w3schools.com › css › css_table.asp
CSS Styling Tables
To control the space between the border and the content in a table, use the padding property on <td> and <th> elements: ... The CSS border-spacing property sets the distance between the borders of adjacent cells.
🌐
W3Schools
w3schools.com › html › html_table_borders.asp
HTML Table Borders
Skip the border around the table by leaving out table from the css selector: th, td { border: 1px solid black; border-radius: 10px; } Try it Yourself » · With the border-style property, you can set the appearance of the border.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › Reference › Properties › border-style
border-style - CSS | MDN
2 weeks ago - When applied to a table cell with border-collapse set to collapsed, this value behaves like groove. border-style = <'border-top-style'>{1,4} <border-top-style> = <line-style> <line-style> = none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset
🌐
PureCode AI
blogs.purecode.ai › home › guide to css table border: make data easily readable
Guide to CSS Table Border: Make Data Easily Readable - Blogs
September 7, 2025 - This CSS code applies a solid, 1-pixel-wide black border to each cell (<td> or <th>) within a row (<tr>). If you want to create internal line borders within a table, you can apply the border style to the <td> and <th> elements directly.
🌐
wpDataTables
wpdatatables.com › home › blog › html table borders: the complete guide to creating, styling, and customizing
HTML Table Borders: The Complete Guide to Creating, Styling, and Customizing
2 days ago - This guide explains how to create and style table borders step by step. You’ll see practical examples for basic HTML tables, learn how to apply CSS for precise customization, and discover solutions for common display issues.
🌐
Screenstepslive
utah.screenstepslive.com › a › 1864861-table-borders-and-shading
Table Borders and Shading | Advanced HTML Elements | University of Utah
August 23, 2024 - In addition, much like image borders, you can specify table borders using (border), (border-top), (border-right), (border-bottom), or (border-left) followed by the desired border width (border-width), color (border-color) and style (border-style), or you can specify all three at once using, ...
🌐
EITCA
eitca.org › home › how can you add borders to a table using css?
How can you add borders to a table using CSS? - EITCA Academy
August 7, 2023 - In this answer, we will explore the different ways to add borders to a table in CSS. 1. Adding Borders to the Table: To add a border to the entire table, you can use the "border" property. This property sets the width, style, and color of all four borders of the table simultaneously.
Find elsewhere
🌐
CSS-Tricks
css-tricks.com › table-with-borders-only-on-the-inside
4 Ways to Make a Table With Borders Only On The Inside (Tic-Tac-Toe Style) | CSS-Tricks
January 5, 2022 - All that’s needed is to add a transparent border to the table element that is 1px wider than the border on the cells and as per border conflict resolution the wider border should be used in favour of the narrower border.
🌐
GeeksforGeeks
geeksforgeeks.org › css › how-to-apply-border-inside-a-table
How to apply border inside a table - CSS
July 12, 2025 - Applying a border inside a table involves setting border properties to table elements. Use CSS to specify border width, style, and color.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › Reference › Properties › border-right-style
border-right-style - CSS | MDN
1 month ago - css · /* Define look of the table */ table { border-width: 2px; background-color: #52e385; } tr, td { padding: 3px; } /* border-right-style example classes */ .b1 { border-right-style: none; } .b2 { border-right-style: hidden; } .b3 { border-right-style: dotted; } .b4 { border-right-style: dashed; } .b5 { border-right-style: solid; } .b6 { border-right-style: double; } .b7 { border-right-style: groove; } .b8 { border-right-style: ridge; } .b9 { border-right-style: inset; } .b10 { border-right-style: outset; } The other style-related border properties: border-bottom-style, border-left-style, border-top-style, and border-style.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn_web_development › Core › Styling_basics › Tables
Styling tables - Learn web development | MDN
October 14, 2025 - table { table-layout: fixed; width: 90%; margin: 10px auto; border-collapse: collapse; border-top: 1px solid #999999; border-bottom: 1px solid #999999; } Save and refresh; your table should be starting to look pretty readable now! We wanted to dedicate a separate section to showing you how ...
🌐
Reddit
reddit.com › r/css › override table border
r/css on Reddit: Override Table border
February 12, 2015 -

I have written some CSS which basically places a 1px solid black border around all my tables, rows and cells. I have done this without using a class by specifying the tags for <table>, <td> and <tr> etc.

I am struggling trying to remove the border using a class - I thought this would work as as I thought a class was more 'specific'.

Can anyone suggest why I am unable to remove the border from my table although it is successfully removing the border from the rows and cells?

https://jsfiddle.net/paulwoody/zee1aLsj/

No I know I should have used a class and that is probably the way I will rewrite my site but I am curious to know what I am doing wrong.

🌐
Quackit
quackit.com › html › codes › tables › html_table_border.cfm
HTML Table Border
HTML table borders are specified using Cascading Style Sheets (CSS).
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-style-a-table-with-css
How to Format and Style HTML Tables Using CSS | DigitalOcean
July 18, 2025 - Learn how to style an HTML table with CSS using borders, padding, and zebra stripes. Follow this step-by-step guide to create clean and accessible tables today.
🌐
ThoughtCo
thoughtco.com › add-internal-lines-to-table-with-css-3469872
How to Add Internal Lines (Borders) in a Table With CSS
November 10, 2019 - Use the border-collapse property in CSS to create single lines between table cells. The HR tag or pseudo-classes like nth-child can help place lines inside or between cells. This article explains how to add internal lines to cells with CSS table ...
🌐
Geekster
geekster.in › home › html table border
HTML Table Border
June 25, 2024 - To begin with a straightforward border on tables, header cells (th), and data cells (td), leverage the CSS border property.
🌐
GeeksforGeeks
geeksforgeeks.org › html › html-table-borders
HTML Table Borders - GeeksforGeeks
July 23, 2025 - Table Borders Style applies the border-collapse: collapse property to the <table>, <td>, and <th> elements, and sets the border and background-color properties for styling the table and its elements.
🌐
HTML AM
html.am › html-codes › tables › table-border.cfm
Table Border
When you apply CSS border code to the table element (i.e. the <table> tag), the border only appears around the actual table - not the individual cells. ... You can also change the border style to thick, dotted, dashed, or anything that CSS understands. You can change its color too.
🌐
Tailwind CSS
tailwindcss.com › docs › border-collapse
border-collapse - Tables - Tailwind CSS
Use the border-collapse utility to combine adjacent cell borders into a single border when possible: <table class="border-collapse border border-gray-400 ..."> <thead> <tr> <th class="border border-gray-300 ...">State</th> <th class="border border-gray-300 ...">City</th> </tr> </thead> <tbody> <tr> <td class="border border-gray-300 ...">Indiana</td> <td class="border border-gray-300 ...">Indianapolis</td> </tr> <tr> <td class="border border-gray-300 ...">Ohio</td> <td class="border border-gray-300 ...">Columbus</td> </tr> <tr> <td class="border border-gray-300 ...">Michigan</td> <td class="border border-gray-300 ...">Detroit</td> </tr> </tbody></table>