Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put a bit of space between table footer/header and body content?

I want to put a bit of space between HTML table header and footer, and my body content. I though margin-top and margin-bottom would do it, but it does not. Yet the font-weight: bold; directive is taken into account.

My HTML:

<table id="myTbl">
   <thead>
     <tr>
       <th>My Table Header</th>
     </tr>
   </thead>  
   <tbody>
    <tr>
      <td>My Body Content</td>
    </tr>
    </tbody>
   <tfoot>
     <tr>
       <th>My Table Footer</th>
     </tr>
   </tfoot>  
</table>

My CSS:

#myTbl {
    font-weight: normal;
}

#myTbl thead {
    font-weight: bold;
    margin-bottom: 10px;
}

#myTbl tfoot {
    font-weight: bold;
    margin-top: 10px;
}

The JSFiddle is available here. I am using Chrome.

like image 376
Jérôme Verstrynge Avatar asked Aug 21 '13 12:08

Jérôme Verstrynge


People also ask

How do you add space between footer and body in HTML?

In your . footer class, in the CSS file, add the display: inline-block; and remove the padding property. margin-top: 2%; is just an example, put any value you want.

How do you add space to a table header in HTML?

The HTML <table> cellspacing Attribute is used to specify the space between the cells. The cellspacing attribute is set in terms of pixels. Attribute Values: pixels: It sets the space between the cells in terms of pixels.

How do I reduce the space between header and body in HTML?

Just set margin:0 in your h1 tag. Save this answer.


1 Answers

try using padding on the th elements.

#myTbl {
    font-weight: normal;
}

#myTbl thead tr th{
    font-weight: bold;
    padding-bottom: 10px;
}

#myTbl tfoot tr th{
    font-weight: bold;
    padding-top: 10px;
}

http://jsfiddle.net/nCe3k/9/

like image 183
james31rock Avatar answered Nov 15 '22 20:11

james31rock