Reputation: 323
I am trying to create a table that looks like this using classic HTML table constructs:
Thinking left to right I came up with the following HTML which was a disaster. Am I missing something?
<html>
<body>
<table border = 1 width=640 height=480>
<tr>
<td rowspan=2 colspan=2>1</td>
<td rowspan=4 colspan=4>2</td>
<td rowspan=2 colspan=2>3</td>
<tr>
<td rowspan=2 colspan=2>4</td>
<td rowspan=2 colspan=2>5</td>
</tr>
<tr>
<td rowspan=4 colspan=4>6</td>
<td rowspan=2 colspan=2>7</td>
<td rowspan=1 colspan=1>8</td>
<td rowspan=1 colspan=1>9</td>
</tr>
<tr>
<td rowspan=1 colspan=1>10</td>
<td rowspan=1 colspan=1>11</td>
</tr>
<tr>
<td rowspan=2 colspan=2>12</td>
<td rowspan=2 colspan=2>13</td>
</tr>
</table>
</body>
</html>
Upvotes: 1
Views: 4026
Reputation: 919
One table styled with CSS.
HTML
<table>
<tr>
<td class="green"></td>
<td colspan="2" rowspan="2" class="red"></td>
<td class="green" colspan="2"></td>
</tr>
<tr>
<td class="green"></td>
<td class="green" colspan="2"></td>
</tr>
<tr>
<td colspan="2" rowspan="3" class="red"></td>
<td rowspan="2" class="green"></td>
<td class="blue"></td>
<td class="blue"></td>
</tr>
<tr>
<td class="blue"></td>
<td class="blue"></td>
</tr>
<tr>
<td class="green"></td>
<td colspan="2" class="green"></td>
</tr>
</table>
CSS
table {
table-layout: fixed;
border-collapse: collapse;
max-width: 8em;
width: 100%;
}
td {
border: 1px solid white;
}
.green {
background: rgb(155,187,89);
height: 2em;
width: 2em;
}
.red {
background: rgb(192,80,77);
height: 4em;
width: 4em;
}
.blue {
background: rgb(79,129,189);
height: 1em;
width: 1em;
}
Result
Upvotes: 3
Reputation: 22382
Here is the code for you. I hope this becomes useful to you because I spent an hour trying to create this for you. (notice HTML 5 recommends using CSS but since you wanted this in just classic html here is the solution for you)
<table width="800" height="400">
<tr width=50%>
<td width="33%" bgcolor="#6CBB3C"></td>
<td width="33%" rowspan="2" bgcolor="#C24641" width=40%></td>
<td width="33%" bgcolor="#6CBB3C"></td>
</tr>
<tr width=50%>
<td width="33%" bgcolor="#6CBB3C"></td>
<td width="33%" bgcolor="#6CBB3C"></td>
</tr>
</table>
<table width="800" height="400">
<tr width="50%">
<td width="50%" rowspan="2" bgcolor="#C24641" width=40%></td>
<td width="25%" bgcolor="#6CBB3C"></td>
<td width="25%" bgcolor="#6CBB3C" height="200pix" bgcolor="white">
<table width="100%" height="200pix" bordercolor="white"
bgcolor="white">
<tr>
<td bgcolor="#7A5DC7"></td>
<td bgcolor="#7A5DC7"></td>
</tr>
<tr>
<td bgcolor="#7A5DC7"></td>
<td bgcolor="#7A5DC7"></td>
</tr>
</table>
</td>
</tr>
<tr width="50%">
<td bgcolor="#6CBB3C"></td>
<td bgcolor="#6CBB3C"></td>
</tr>
</table>
here is the result for you:
Upvotes: 3