Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

My html cell (td) border color is overiding the table border color. How can I prevent this?

I have a table with one row and four cells.
I want that inside the table the td border colour is active, but the table outer border color should be as defined in the table css properties.

For achieving that I have added !important to the table border definition. But still the td border definition is overriding it. How can I prevent this?

.td_table {
  border: 1pt solid #B5B5B5;
}

.table_1 {
  border: 1px solid black !important;
}
<table class="table_1">
  <tr max-height="35">
    <td class="td_table">...</td>
    <td class="td_table">...</td>
    <td class="td_table">...</td>
    <td class="td_table">...</td>
  </tr>
</table>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The table’s outer border color is defined by the .table_1 class and the inner cell borders are defined by the .td_table class without being overridden, you can apply a separate border style to the table cells ( elements) directly.

.td_table {
  border: 1pt solid #B5B5B5;
}

.table_1 {
  border: 1px solid black !important;
}

.table_1 td {
  border: none; /* Resetting the border for all table cells */
}
<table class="table_1">
  <tr max-height="35">
    <td class="td_table">...</td>
    <td class="td_table">...</td>
    <td class="td_table">...</td>
    <td class="td_table">...</td>
  </tr>
</table>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading