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 OverflowW3Schools
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.
Videos
08:41
CSS Table Border Tutorial - Better Than HTML Table Borders - YouTube
08:10
HTML and CSS Tutorial Series Part 6 Style Table Borders - YouTube
11:53
🔥 How to Design a Stunning Table Using CSS (Step-by-Step Tutorial!)
05:08
HTML - From Zero to Hero #24 - Table Borders - YouTube
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
Screenstepslive
utah.screenstepslive.com › a › 1864861-table-borders-and-shading
Table Borders and Shading | Advanced HTML Elements | University of Utah
August 23, 2024 - <table style="border: 1px solid; max-width: 100%; min-width: 40%; margin: 1.5rem auto; float: left;"> <caption>Table with Shaded Row</caption> <colgroup> <col style="border: 1px solid;" /> <col style="border: 1px solid;" /> <col style="border: 1px solid;" /> </colgroup> <thead> <tr style="border: ...
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.
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.
Top answer 1 of 3
2
https://jsfiddle.net/zee1aLsj/4/ your "table .noborder" is targeting an element with a class of noborder inside of a table, that's why the border remains on the table element. Change to just .noborder or table.noborder (if you need to be more specific for some reason) and it works.
2 of 3
1
table, tbody, td, th, tr { border: 1px solid black; } .noborder table, .noborder tbody, .noborder td, .noborder th, .noborder tr { border: none; }
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.
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>