Yellow Flash
Yellow Flash

Reputation: 872

how to break a line or space in between two rows of the html table

I need to give space or break between two rows, so that my page will looks good.

if you look my code i had given many empty rows and column to make a space between two rows in the table.

Please say any other proper way to give space between two rows.

here is my sample code:

<form:form name="form" method="post" modelAttribute="Abatch">

 <table>
<tr>
    <td>Please enter your comments</td>
    <td><form:textarea id="textarea" style="width:150%;height:150%" path="Comments" size="255" readonly="false" /></td>
</tr>
<tr>
<tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
</tr>
</tr>
<tr>     
   <td><input id="button1"   type="submit" name="submit" value="Approve"/></td>
   <td><input id="button4"  type="submit" name="submit" value="Reject"/></td>

  </tr>
</table>

Upvotes: 9

Views: 95576

Answers (7)

Pukhraj soni
Pukhraj soni

Reputation: 2140

The solution worked for me is defining css properties at column level and defining colspan as the number of columns in the table

Html -

<tr class="border_bottom">
    <td colspan="6"></td>
</tr>

CSS -

tr.border_bottom td {
    border-bottom: 1px solid #cccccc;
    color: #707070;
}

table{
    border-collapse: collapse;
}

Upvotes: 0

anand24
anand24

Reputation: 321

This can be achieved like this.

<tr> <td> <br> </td> <!--The br tag did what i was looking for --> </tr>

Upvotes: 3

MJ33
MJ33

Reputation: 889

Try this:

<tr>
    <td>
        Row 1
    </td>
</tr>
<tr>
    <td>
        &nbsp;
        <!--you just need a space in a row-->
    </td>
</tr>
<tr>
    <td>
        Row 2
    </td>
</tr>

Upvotes: 25

Marc Audet
Marc Audet

Reputation: 46785

According to the CSS box model:

margin values do not apply to table rows and table cells
See: http://www.w3.org/TR/CSS2/box.html#margin-properties

padding and border values do not apply to table rows but apply to table cells
See: http://www.w3.org/TR/CSS2/box.html#padding-properties

A quick fix is to add padding to the top of the row that you want to separate.

For example: http://jsfiddle.net/audetwebdesign/caXsZ/

Sample HTML:

<table cellpadding="0" cellspacing="0" border="0">
    <tr class="row1">
        <td>Row One - 1</td>
        <td>Row One - 2</td>
    </tr>
    <tr class="row2">
        <td>Row Two - 1</td>
        <td>Row Two - 2</td>
    </tr>    
</table>

CSS:

td {
    border: 1px dotted blue;
}
tr.row2 td {
    padding-top: 40px;
}

If you want to style borders around your table cells, you may need to add wrappers around the content and apply borders depending on the design details.

Upvotes: 10

Charaf JRA
Charaf JRA

Reputation: 8334

The correct way to give spacing for tables is to use cellpadding and cellspacing e.g.

<table cellpadding="4">

or using css :

<style type='text/css'>    
  table{ border-collapse: separate; }
  table td { border-spacing: 1em; }
</style>

Upvotes: 4

Sudharsun
Sudharsun

Reputation: 761

border spacing attribute has to be specified in CSS

table
    {
    border-collapse:separate;
    border-spacing:10px 0px;
    }

The above code set 10px spacing between the rows and 0px spacing between the columns

Upvotes: 4

Gustavo Gondim
Gustavo Gondim

Reputation: 1643

Set the marginattribute for a <tr> tag:

<tr style="margin-top:10px;"></tr>

Or make the entire table with this style:

<style>
    table tr {
        margin-top: 10px;
    } 

    table tr:first-child {
       margin-top: 0px; !important
    }
</style>

Upvotes: 1

Related Questions