Lining up table header borders with table body borders
I'm going through codecademy's Full Stack Dev course. The project I'm on currently is to develop a cheat sheet which includes a table.
I want to have it such that the "borders" in the table head row line up vertically with those in the body column, with those in the head row inheriting the background colour, and those in the body taking the assigned rgb.
It currently looks like the picture. Here is my CSS code:
Probably forgetting something really stupid. Any help massively appreciated.

15 Replies
If the table head and table body all form part of the same table, the borders will line up automatically.
I notice in your code that you haven't defined a style or color for the
thead th
borders. You need to define these for the border to appear.why do you have
border-collapse
set to separate
and then a border-spacing
?Hello both, thanks for the replies. @ἔρως I think this is an area where I was lacking understanding. It was a (clumsy) attempt at instituting spacing. Would the border-spacing override the border-collapse?
no, it will just add weird spacing
the main problem is that you have
border-left
without collapsing borders and with a border spacing
just collapse the borders, put the borders on all sides, use padding in the td
or th
and for the outside, just use a white border and pink background with padding
or margin, depending on what works
oh, and on the top, use white borderstable cells are weird. The white bit between the THs isn't the border that's defined with the css border property
it's the border spacing
border-left: 2px
doesn't do anything unless you also define a color and a fill typegood catch

dont forget the white and pink outside the table
is that even intentional?
🤔
:think:
maybe not
but looks good
at least to my bad designer self
Excellent, thank you all
tables are a huge pita, you wont work with these a ton