user1573659
user1573659

Reputation: 29

HTML table setting td height wont work

I have a problem with Internet Explorer 9 and fixed height of a td

I need a td with 5px height but in IE9 its bigger than 5px.

In Chrome, Firefox and Safari it works

I tried with a transparent 1px gif to insert in the td, I set the font-size: 0px; line-height: 0px and it still won't work.

My test code:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>test</title>
<style>
    .space{
        height: 5px;
        width: 5px;
        font-size: 0px;
        line-height: 0px;
        background: none;
    }

    table{
        border-spacing: 0px;
        table-layout: fixed;

    }

    td{
        background-color: red;
    }

</style>
</head>

<body>

    <table cellpadding="0" cellspacing="0" style="width: 1200px;">
        <tr >
            <td rowspan="5"> test1<br>test1<br>test1<br>test1<br>test1<br>test1<br>test1<br>test1<br>test1<br>test1<br><br>test1<br>test1<br>test1<br>test1<br>test1<br>test1<br>test1<br>test1<br>test1<br> </td>
            <td rowspan="5" class="space"> </td>
            <td rowspan="5"> test2<br>test1<br>test1<br>test1<br>test1<br>test1<br>test1<br>test1<br>test1<br>test1<br><br>test1<br>test1<br>test1<br>test1<br>test1<br>test1<br>test1<br>test1<br>test1<br> </td>
            <td rowspan="5" class="space"> </td>
            <td> test3</td>
        </tr>

        <tr>
            <td class="space"> spacer</td>
        </tr>

        <tr>
            <td> test 5</td>
        </tr>

        <tr>
            <td class="space"> spacer</td>
        </tr>

        <tr>
            <td> test 5</td>
        </tr>
  </table>

</body>
</html>

I have two images:

Chrome (working):

chrome(working)

IE9:

ie9

Upvotes: 0

Views: 5012

Answers (1)

maceyj2
maceyj2

Reputation: 666

You can place a div inside the td with a height of 5px. http://jsfiddle.net/aCrbz/3/

<td><div class="foo"></div></td>

Upvotes: 1

Related Questions