Reputation: 49228
In Firefox, "C" is centered, due to the CSS blurb at the beginning. Why does IE7 left-justify it?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<style type="text/css">
td {
text-align: center;
width: 130px;
}
</style>
</head>
<body>
<div style="width: 300px; background-color: #888">
<table>
<tbody>
<tr>
<td>A</td>
<td>B</td>
</tr>
<tr>
<td colspan="2">C</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Upvotes: 0
Views: 2061
Reputation:
always use this for position a object in center in your page this feature is worked in all popular browser like IE FF Safari Chrome Opera
<center> This is my centered text</center>
please give me vote if your problem is solved
Upvotes: 0
Reputation: 138117
That happens because you have width: 130px;
. Try setting width only for the small cells, for example by:
td.span {
width:auto;
}
<td colspan="2" class="span">C</td>
See example: http://jsbin.com/etoka
You can also do it the other way around - giving a class to the small cells, the whole row, or best: setting the width of the <table>
.
Upvotes: 4