Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inserting a blank table row with a smaller height

I have a table consisting of a header row and a couple of data rows. What I want to do is to create a blank row in between the header and the data rows, but I want this blank row to be smaller in height than the other rows (so that there isn't such a large gap).

How can I accomplish this?

My HTML mark-up code for the table is as follows:

<table class="action_table">     <tbody>         <tr class="header_row">             <td>Header Item</td>             <td>Header Item 2</td>             <td>Header Item 3</td>         </tr>                     <tr class="blank_row">             <td bgcolor="#FFFFFF" colspan="3">&nbsp;</td>         </tr>         <tr class="data_row">             <td>Data Item</td>             <td>Data Item 2</td>             <td>Data Item 3</td>         </tr>     </tbody> </table> 
like image 675
Ed. Avatar asked Mar 16 '12 14:03

Ed.


People also ask

How do I adjust the size of a table?

Adjust the table size, column width, or row height manually or automatically. You can change the size of multiple columns or rows and modify the space between cells.

How to fix height of row in table column in HTML?

It looks like height of row depends on height of td. So we can put some div and set height to that div to fix height of row. td.table-column > div.item { height: 20px; overflow:hidden; background-color: lightpink; }

How do I set the height and size of a column?

To set the size of a specific column, add the style attribute on a <th> or <td> element: To set the height of a specific row, add the style attribute on a table row element:

Do I need an extra table row to create space?

You don't need an extra table row to create space inside a table. See this jsFiddle. (I made the gap light grey in colour, so you can see it, but you can change that to transparent.) Using a table row just for display purposes is table abuse! Show activity on this post.


2 Answers

Just add the CSS rule (and the slightly improved mark-up) posted below and you should get the result that you're after.

CSS

.blank_row {     height: 10px !important; /* overwrites any other rules */     background-color: #FFFFFF; } 

HTML

<tr class="blank_row">     <td colspan="3"></td> </tr> 

Since I have no idea what your current stylesheet looks like I added the !important property just in case. If possible, though, you should remove it as one rarely wants to rely on !important declarations in a stylesheet considering the big possibility that they will mess it up later on.

like image 192
Tom Avatar answered Sep 19 '22 10:09

Tom


Try this:

<td bgcolor="#FFFFFF" style="line-height:10px;" colspan=3>&nbsp;</td> 
like image 44
Barry Kaye Avatar answered Sep 20 '22 10:09

Barry Kaye