I want to create table with main section and subsections like that
I tried
<html>
<body>
<table style="width:100%">
<tr>
<td rowspan="3">section</td>
<td rowspan="3">subsection1</td>
<td rowspan="2">subsection1</td>
<td rowspan="1">subsection1</td>
</tr>
<tr>
<td>text1</td>
</tr>
<tr>
<td>text2</td>
</tr>
<tr>
<td>text3</td>
</tr>
...
</table>
</body>
</html>
but this code dont create dont create subsections. Surrounding subsection1 with also dont create subsections.
The rowspan attribute indicates the number of rows a cell should take up. There are 6 rows total in your table, so if you want a cell to span to the last row of the table, you specify rowspan="6". Note that the rowspan values should sum up to the same number for each column, the default value being 1.
<table style="width:100%">
<tr>
<td rowspan="6">section</td>
<td rowspan="3">subsection1</td>
<td>text1</td>
</tr>
<tr>
<td>text2</td>
</tr>
<tr>
<td>text3</td>
</tr>
<tr>
<td rowspan="2">subsection2</td>
<td>...</td>
</tr>
<tr>
<td>...</td>
</tr>
<tr>
<td rowspan="1">subsection3</td>
<td>...</td>
</tr>
</table>
See this JSFiddle
Related
I am trying to add a row with double height to that of other row. But unable to make. Not sure what is wrong.
<table border="1">
<tr>
<td rowSpan="2">A1</td>
<td rowSpan="2">A2</td>
<td rowSpan="2">A3</td>
<td rowSpan="2">A4</td>
</tr>
<tr>
</tr>
<tr>
<td>C1</td>
<td>C2</td>
<td>C3</td>
<td>C4</td>
</tr>
</table>
You'll need some css to set the height of the row;
table td, tr {
height: 30px;
}
table td, tr {
height: 30px;
}
<table border="1">
<tbody>
<tr>
<td rowSpan="2">A1</td>
<td rowSpan="2">A2</td>
<td rowSpan="2">A3</td>
<td rowSpan="2">A4</td>
</tr>
<tr>
</tr>
<tr>
<td>C1</td>
<td>C2</td>
<td>C3</td>
<td>C4</td>
</tr>
</tbody>
</table>
Note; You should add a tbody to your table; What is the purpose for HTML's tbody?
Are you trying to do that ?
<table border="1">
<tr>
<td>A1</td>
<td>A2</td>
<td>A3</td>
<td rowspan="2">A4/B4 <br>(2 rows)</td>
</tr>
<tr>
<td>B1</td>
<td>B2</td>
<td>B3</td>
</tr>
<tr>
<td>C1</td>
<td colspan="2">C2/C3 <br>(2 cols)</td>
<td>C4</td>
</tr>
</table>
The rowspan property should only be used if you are trying to have one cell appear across two rows (as if you are using the Merge Cells functionality on Excel). If you want to make one row twice as high as the other, this is a display property and should be done with css or inline styling. The middle (row) should also be removed.
If this is just a general example and you need to use it on something more complex. If you use rowspan on say 1 element, you will need to make sure that the following row has 1 less td element otherwise it will not display correctly.
<table border="1">
<tr style="height: 50px">
<td >A1</td>
<td >A2</td>
<td >A3</td>
<td >A4</td>
</tr>
<tr>
<td>C1</td>
<td>C2</td>
<td>C3</td>
<td>C4</td>
</tr>
</table>
I have a table structure like this
And the html structure is this
<table class="table table-bordered">
<thead>
<tr>
<th>Hierarchy</th>
<th>Operations</th>
</tr>
</thead>
<tbody>
<tr>
<td class="history-hierarchy" rowspan="4">
<div><!-- Tree structure is loaded here dynamically --></div>
</td>
</tr>
<tr>
<td class="history-text">
Equipment A700/005 is added.
</td>
</tr>
<tr>
<td class="history-text">
System instance SYSI/0002 is added.
</td>
</tr>
<tr>
<td class="history-text">
Equipment 7100/001 is replaced with 7100/002
</td>
</tr>
</tbody>
</table>
If you see the image, the Operations columns height is adjusting itself based on the Hierarchy columns height, I am looking for some way if possible to have the heights of operation column fixed say 10px and whatever space is left the last row's operation column should consume it.
So the operations column will not looke weird having so much height.
Is it possible?
the approach you are using is correct, you can use rowspan="2" on the last row as shown in my snippet.
table {height: 600px}
table td {border:1px solid red; vertical-align:top}
td.history-text {height: 20px}
<table class="table table-bordered">
<thead>
<tr>
<th>Hierarchy</th>
<th>Operations</th>
</tr>
</thead>
<tbody>
<tr>
<td class="history-hierarchy" rowspan="4">
<div>Tree structure is loaded here dynamically</div>
</td>
<td class="history-text">
Equipment A700/005 is added.
</td>
</tr>
<tr>
<td class="history-text">
System instance SYSI/0002 is added.
</td>
</tr>
<tr>
<td class="history-text" rowspan="2">
Equipment 7100/001 is replaced with 7100/002
</td>
</tr>
</tbody>
</table>
I want to achieve this:
and I did these with <td> tag but only col span is working correctly
<tr>
<td><input type="checkbox"></td>
<td>hu043</td>
<td>7903</td>
<td>90df78</td>
</tr>
<tr>
<tr>
<td colspan="4" rowspan="4"> </td>
</tr>
The purpose of rowspan is to span existing rows, like you are spanning existing columns in your example.
If you will add some rows below, you will see it.
<tr>
<td colspan="4" rowspan="4"> </td>
</tr>
<tr style='height:20px;'></tr>
<tr style='height:20px;'></tr>
<tr style='height:20px;'></tr>
How I close this gap between the inner table and the main table cell?
https://jsfiddle.net/w7eekbcL/2/
<td>
<table style="width:100%">
<tr>
<td colspan="2" style="font-family:verdana; color:#424242">main list</td>
</tr>
<tr>
<td colspan="2">list</td>
</tr>
<tr>
<td colspan="2">• one</td>
</tr>
<tr>
<td colspan="2">• second</td>
</tr>
<tr>
<td colspan="2">• thurd</td>
</tr>
</table>
</td>
For example I tried to use text-aligment but the result is the same.
Add vertical-align: top to the td that contains the table.
Is it possible to lay out a table with 2 columns. The first column with many td's, the second one with only one?
Yes, use colspan...or you might want rowspan (colspan's opposite :))
Directly from the article (with enclosing the attributes in quotes:
<TABLE BORDER="2" CELLPADDING="4">
<TR> <TH COLSPAN="2">Production</TH> </TR>
<TR> <TD>Raha Mutisya</TD> <TD>1493</TD> </TR>
<TR> <TD>Shalom Buraka</TD> <TD>3829</TD> </TR>
<TR> <TD>Brandy Davis</TD> <TD>0283</TD> </TR>
<TR> <TH COLSPAN="2">Sales</TH> </TR>
<TR> <TD>Claire Horne</TD> <TD>4827</TD> </TR>
<TR> <TD>Bruce Eckel</TD> <TD>7246</TD> </TR>
<TR> <TD>Danny Zeman</TD> <TD>5689</TD> </TR>
</TABLE>
Here is the W3 article
yes use rowspan or colspan to merge td. Example:
<table>
<tr>
<td></td><td></td><td></td>
</tr>
<tr>
<td rowspan="3"></td>
</tr>
</table>