Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can someone please tell me how I can make the adjacent horizontal borders of the 2 adjoining tables collapse so that they conform to the rest of the table borders? Thank you.

HTML
<!DOCTYPE HTML>

    /* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 100%;
	font: inherit;
	vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section, paragraph {
	display: block;
}
body {
	line-height: 1;
}
ol, ul {
	list-style: none;
}
blockquote, q {
	quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
	content: '';
	content: none;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}
    /*THIS IS THE END OF THE MYER RESET*/
    
table {
    margin: auto;
    border-collapse: collapse;
    }
table, td {
    border: 2px solid black;
    }
td {
    padding: 30px;
    background-color: #ededed;
    }
td img{
    display: block;
    margin-left: auto;
    margin-right: auto;
}
    
    
              
            
            <table><tbody><tr>           <td>Cell A1</td><td>Cell A2</td><td>Cell A3</td>        </tr>    </tbody></table>
    
              

              
    <table class="table1"><tbody><tr class="table1">            <td class="table1">Cell B1</td><td class="table1">Cell B2</td><td class="table1">Cell B3</td><td class="table1">Cell B4</td></tr>    </tbody></table>


What I have tried:

I created a class with border-collapse: collapse and assigned that to the table, the table row, and the td collectively and separately for the 2nd table but it had no effect.
Posted
Updated 7-May-18 4:55am
v4

1 solution

You can't collapse the border of two tables like that unfortunately, but it would be an option to hide the bottom border of your first table:

CSS:
.table0
{
    border-bottom:0px;
}


HTML:
<table class="table0">
    <tbody>
        <tr>
            <td class="table0">Cell A1</td>
            <td class="table0">Cell A2</td>
            <td class="table0">Cell A3</td>
        </tr>
    </tbody>
</table>


Alternatively you could hide the top border of the second table (table1), depending on which is wider.
 
Share this answer
 
Comments
Member 13798280 7-May-18 19:28pm    
Since these were tables with differing numbers of columns (tables of different widths), wouldn't zeroing out one of the borders mean that the border would not show up for the entire width, so that some cells would not have a top or bottom in either case?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900