Rama Rao M Rama Rao M - 1 month ago 7
HTML Question

Table colspan looks different

I have a table of 2 rows and 3 columns and I want to set

colspan=2
to
1x2 cell
and
2x1 cell
.
But output seems something different than I expected.

Expected one:
enter image description here

But the output that's shown:
enter image description here

Here is the html:

<!DOCTYPE HTML PUBLIC>
<html>
<body>
<table border=1 cellpadding=0 cellspacing=0 width=100%>
<tr>
<td >1x1</td>
<td COLSPAN=2>1x2</td>
</tr>
<tr>
<td COLSPAN=2>2X1</td>
<td>2x2</td>
</tr>
</table>
</body>
</html>


Can somebody help me to achieve the expected output using table and colspan?

Answer

Add the following CSS class:

table {
    table-layout: fixed;
}

FIDDLE