I have a problem with making a table in HTML.
The table should look like in this image:
And the second image is how I made:
This is my code:
<table width="730" border="1px" cellspacing="0" cellpadding="3">
<tr align="center">
<td rowspan="3">A</td>
<td rowspan="2">B</td>
<td rowspan="3">D</td>
<td>E</td>
<td>F</td>
<td>G</td>
</tr>
<tr align="center">
<td rowspan="2" colspan="3">H</td>
</tr>
<tr align="center">
<td>C</td>
</tr>
</table>
How to create a table like in the first image?
.grey{ background: rgba(128,128,128,0.7); }
<table width="730" border="1px" cellspacing="0" cellpadding="3">
<tr align="center">
<td rowspan="3">A</td>
<td rowspan="2" height="60px">B</td>
<td rowspan="3">D</td>
<td class="grey">E</td>
<td class="grey">F</td>
<td class="grey">G</td>
</tr>
<tr align="center">
<td rowspan="2" colspan="3">H</td>
</tr>
<tr align="center">
<td>C</td>
</tr>
</table>
In this particular case the only things you can do are
1.) Add more content to the cells. If the amount of contents corresponds to the cell heights, they will adjust automatically.
or
2.) If you intend to have as little contents as in your example code, add a height setting to one of the cells that are supposed to span two rows - see snippet below.
<table width="730" border="1px" cellspacing="0" cellpadding="3">
<tr align="center">
<td rowspan="3">A</td>
<td rowspan="2" style="height:3em;">B</td>
<td rowspan="3">D</td>
<td>E</td>
<td>F</td>
<td>G</td>
</tr>
<tr align="center">
<td rowspan="2" colspan="3">H</td>
</tr>
<tr align="center">
<td>C</td>
</tr>
</table>
Related
What do you think should I do to make my code's output like in the photo?
Thank you for answering.
(I am typing any words in here because stackoverflow doesnt let me post this. This is the most detailed thing I can think of. I am new to the programming world and I have no one to assist me that's why I am asking for some help. Thank you for understanding.)
Here's my code:
<table border="1" cellpadding="20% " width="20%" cellspacing="0">
<tr>
<td rowspan="10"></td>
<td colspan="9"></td>
</tr>
<tr>
<td rowspan="9"></td>
<td colspan="8"></td>
</tr>
<tr>
<td rowspan="8"></td>
<td colspan="7"></td>
</tr>
<tr>
<td rowspan="7"></td>
<td colspan="6"></td>
</tr>
<tr>
<td rowspan="6"></td>
<td colspan="5"></td>
</tr>
<tr>
<td rowspan="5"></td>
<td colspan="4"></td>
</tr>
<tr>
<td rowspan="4"></td>
<td colspan="3"></td>
</tr>
<tr>
<td rowspan="3"></td>
<td colspan="2"></td>
</tr>
<tr>
<td rowspan="2"></td>
<td colspan="1"></td>
</tr>
<tr>
<td rowspan="0">
</td>
</tr>
</table>
enter image description here
make table inside td
<td rowspan="0" style="padding: 0; border: none;">
<table border="1" cellpadding="10% " width="20%" cellspacing="0">
<tr>
<td></td>
<td></td>
</tr><tr>
<td></td>
<td></td>
</tr>
</table>
</td>
<table border="1" cellpadding="20% " width="20%" cellspacing="0">
<tr>
<td rowspan="10"></td>
<td colspan="9"></td>
</tr>
<tr>
<td rowspan="9"></td>
<td colspan="8"></td>
</tr>
<tr>
<td rowspan="8"></td>
<td colspan="7"></td>
</tr>
<tr>
<td rowspan="7"></td>
<td colspan="6"></td>
</tr>
<tr>
<td rowspan="6"></td>
<td colspan="5"></td>
</tr>
<tr>
<td rowspan="5"></td>
<td colspan="4"></td>
</tr>
<tr>
<td rowspan="4"></td>
<td colspan="3"></td>
</tr>
<tr>
<td rowspan="3"></td>
<td colspan="2"></td>
</tr>
<tr>
<td rowspan="2"></td>
<td colspan="1"></td>
</tr>
<tr>
<td rowspan="0" style="padding: 0; border: none;">
<table border="1" cellpadding="10% " width="20%" cellspacing="0">
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
</td>
</tr>
</table>
In this image two columns are spanned equal to three columns
How can I achieve this in my situation,
<table border="1">
<tr>
<td colspan="3">Top</td>
</tr>
<tr>
<td>Left</td>
<td>Center</td>
<td>Right</td>
</tr>
<tr>
<td>Left</td>
<td>Right</td>
</tr>
</table>
<table border="1">
<tr>
<td colspan="6">Top</td>
</tr>
<tr>
<td colspan="2">Left</td>
<td colspan="2">Center</td>
<td colspan="2">Right</td>
</tr>
<tr>
<td colspan="3">Left</td>
<td colspan="3">Right</td>
</tr>
</table>
I have some HTML code and would like to remove the outer borders of a <table>
<table class="table1">
<tr>
<tr>
<tr>
<th colspan="4" class="tableheader"><center>Tarieventabel 2019</center></th>
</tr>
<tr>
<td class="description"></td>
<td class="description"><b><center>Van</center></b></td>
<td class="description"><b><center>Tot</center></b></td>
<td class="description"><b><center>Prijs</center></b></td>
You can solve with using css.
<table class="borderNone" style="border:none;">
<tr>
<tr>
<tr>
<th colspan="4" class="tableheader">
<center>Tarieventabel 2019</center>
</th>
</tr>
<tr>
<td class="description"></td>
<td class="description"><b><center>Van</center></b></td>
<td class="description"><b><center>Tot</center></b></td>
<td class="description"><b><center>Prijs</center></b></td>
</tr>
</table>
Or using css classes
.borderNone{ border: none;}
It seems easy but can't write the HTML code of the above table.
Here is what I tried so far:
<table border="1" style="border-collapse:collapse;" width="25%">
<tr>
<td>col1</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
</table>
Sure you want html??
<table align="center" width="590" height="590" >
<tr>
<td align="center" height="80" colspan="4">central text</td>
</tr>
<tr>
<td align="center" height="80" colspan="2">col</td>
<td align="center" colspan="2">col</td>
</tr>
<tr>
<td align="center" height="40">t</td>
<td align="center" height="40">t</td>
<td align="center" height="80" rowspan="2">t</td>
<td align="center" rowspan="2">t</td>
</tr>
<tr>
<td align="center" height="40">t</td>
<td align="center" height="40">t</td>
</tr>
<tr>
<td align="center" height="30">t</td>
<td align="center" >t</td>
<td align="center" >t</td>
<td align="center" >t</td>
</tr>
</table>
Like this?
colspan and rowspan was missing from your code.
<table border="1" style="border-collapse: collapse;">
<tr>
<td colspan=4 align="center">central text</td>
</tr>
<tr>
<td colspan=2 align="center">col(1)</td>
<td colspan=2 align="center">col(2)</td>
</tr>
<tr>
<td align="center">text</td>
<td align="center">text</td>
<td rowspan=2 align="center">text</td>
<td rowspan=2 align="center">text</td>
</tr>
</tr>
<tr>
<td align="center">text</td>
<td align="center">text</td>
</tr>
<tr>
<td align="center">text</td>
<td align="center">text</td>
<td align="center">text</td>
<td align="center">text</td>
</tr>
</table>
I'm trying to create this shape with tables:
My html code is this:
<html>
<head>
<title>Exercise!</title>
</head>
<body>
<table border="1" width="100%" height="100%">
<tr>
<td colspan="2"></td>
<td colspan="3"></td>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="1"></td>
<td colspan="2"></td>
<td colspan="1"></td>
<td colspan="2"></td>
<td colspan="1" rowspan="2"></td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="1"></td>
<td colspan="2"></td>
<td colspan="1"></td>
</tr>
</table>
</body>
</html>
This html code gets me this wrong shape:
But when I add a row without colspan and rowspans, the browser shows this correct shape but with an extra row:
Here is the code that creates the correct shape but with an extra row:
<html>
<head>
<title>Exercise!</title>
</head>
<body>
<table border="1" width="100%" height="100%">
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="3"></td>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="1"></td>
<td colspan="2"></td>
<td colspan="1"></td>
<td colspan="2"></td>
<td colspan="1" rowspan="2"></td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="1"></td>
<td colspan="2"></td>
<td colspan="1"></td>
</tr>
</table>
</body>
</html>
What is the problem?
EDIT : IE shows a big blank rectangle!!!! Also what is this problem?
problem is likely the borders. When you add the row with all the fields specified, it draws a border between each field for all fields, but without that row, some of the borders are not drawn, so some rows have less pixels than others
Works wonderfully for me in WebKit. Get rid of the borders on each tr for sure. What browser are you using? (Also, I added a rowspan.)
fiddle: http://jsfiddle.net/whqVC/