create a table with thead wider than the table itself - html

I have a very basic table, made up of 3 rows and 3 columns, and i'm trying to make it look like in this picture
(that is, the thead should be wider than the other rows). How do i achieve this effect? I tried with colspan but i can't get it right. The basic table is something like:
<table>
<thead>
<tr>
<th>Extra details</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
</tbody>
</table>
Thanks!

You need to add colspan="3" to the th (number of cols must be identical in all tr in a table). Then make every last td in each tr much wider than the first two (using :last-child pseudo selector, see https://developer.mozilla.org/en-US/docs/Web/CSS/:last-child).
table {
width: 100%;
}
thead th {
background-color: #ddd;
}
td:last-child {
width: 60%;
}
<table>
<thead>
<tr>
<th colspan="3">Extra details</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
</tbody>
</table>

you may use colspan and add a virtual forth col of 50% width:
tbody tr:after {
content: '';
display: table-cell;
width:50%
}
th {
background: gray;
border: solid;
}
table {
width: 100%;
}
<table>
<thead>
<tr>
<th colspan="4">Extra details</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
</tbody>
</table>

You can use the caption element, which spans the table's width and is more semantically correct in your situation since it describes the entire table. Then use a pseudo-element to fill the remaining space in the rows and collapse the other columns.
table {
width: 100%;
}
caption {
border: 2px solid darkgray;
background-color: lightgray;
}
tr:after {
display: table-cell;
content: "";
width: 100%;
}
<table>
<caption>Extra details</caption>
<tbody>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
</tbody>
</table>

Related

How to make css active only in one table? (duplicate table class)

I have 2 tables with same class elements like:
/* and css to make number increases in Numbers List col */
.myTbl tbody {
counter-reset: rowNumber;
}
.myTbl tbody tr {
counter-increment: rowNumber;
}
.myTbl tbody tr td:nth-child(1)::before {
content: counter(rowNumber);
min-width: 1em;
margin-right: 0.5em;
}
<div class="tableRow">
<table class="myTbl">
<thead>
<tr>
<td>Numbers List</td>
<td>Content</td>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>A</td>
</tr>
<tr>
<td></td>
<td>B</td>
</tr>
<tr>
<td></td>
<td>C</td>
</tr>
</tbody>
</div>
<div class="tableRow">
<table class="myTbl">
<thead>
<tr>
<td>C</th>
<td>D</th>
</tr>
</thead>
<tbody>
<tr>
<td>3</td>
<td>4</td>
</tr>
</tbody>
</div>
I want the css only active in specific table like table 1 , but I'm having duplicate classes. How to do it?
And I cant affect the html table like change class or add id,... cause It's exported from other, only js or jquery to do it.
I tried adding ::nth-child(1) not working, is there a way same like eq() in js?
:first-child or nth-child(1) are actually work, you need to select from the parent
body .myTbl:first-child tbody {
counter-reset: rowNumber;
background: yellow
}
<table class="myTbl">
<thead>
<tr>
<td>Numbers List</td>
<td>Content</td>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>B</td>
</tr>
</tbody>
<table class="myTbl">
<thead>
<tr>
<th>C</th>
<th>D</th>
</tr>
</thead>
<tbody>
<tr>
<td>3</td>
<td>4</td>
</tr>
</tbody>
First, you had unclosed tags.
Second, Using pseudo selectors is the key. But there is a difference between :first-child & :first-of-type.
/* and css to make number increases in Numbers List col */
.myTbl tbody {
counter-reset: rowNumber;
}
.myTbl tbody tr {
counter-increment: rowNumber;
}
/* OR :first-child */
.myTbl:first-of-type tbody tr:first-of-type td::before {
content: '•';
min-width: 1em;
margin-right: 0.5em;
}
<table class="myTbl">
<thead>
<tr>
<td>Numbers List</td>
<td>Content</td>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>A</td>
</tr>
<tr>
<td></td>
<td>B</td>
</tr>
<tr>
<td></td>
<td>C</td>
</tr>
</tbody>
</table>
<table class="myTbl">
<thead>
<tr>
<td>C</td>
<td>D</td>
</tr>
</thead>
<tbody>
<tr>
<td>3</td>
<td>4</td>
</tr>
</tbody>
</table>

How to make <div> scrollable from bottom

I made a table inside a div to make it scrollable;
<div style="overflow-y: scroll; height:100px; width:100px;">
<table
<thead>
<tr>
<th>a</th>
<th>b</th>
</tr>
</thead>
<tbody>
<tr>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>b</td>
<td>b</td>
</tr>
<tr>
<td>t</td>
<td>t</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>b</td>
<td>b</td>
</tr>
<tr>
<td>t</td>
<td>t</td>
</tr>
</tbody>
</table>
</div>
This table is scrollable from top to bottom. How can I make the table's overflow start at the bottom and make it scroll upwards?
You need to use javascript for this. Using scrollTop for accessing the scroll offset from the top (default is 0). So you have to get the div's height and set the scrollTop of the div to its height. To get the height, I used getBoundingClientRect().height
let tableDiv = document.getElementById('main');
tableDiv.scrollTop = tableDiv.getBoundingClientRect().height;
<div id="main" style="overflow-y: scroll; height:100px; width:100px;">
<table
<thead>
<tr>
<th>a</th>
<th>b</th>
</tr>
</thead>
<tbody>
<tr>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>b</td>
<td>b</td>
</tr>
<tr>
<td>t</td>
<td>t</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>b</td>
<td>b</td>
</tr>
<tr>
<td>t</td>
<td>t</td>
</tr>
</tbody>
</table>
</div>
Your HTML content:
<div class="scorllable-table" id="scrollTable">
<table>
<thead>
<tr>
<th>a</th>
<th>b</th>
</tr>
</thead>
<tbody>
<tr>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>b</td>
<td>b</td>
</tr>
<tr>
<td>t</td>
<td>t</td>
</tr>
<tr>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>b</td>
<td>b</td>
</tr>
<tr>
<td>t</td>
<td>t</td>
</tr>
</tbody>
</table>
</div>
Your CSS content:
.scorllable-table {
overflow-y: scroll;
height: 100px;
width: 100px;
}
If you want to do this using JavaScript only, then please try with this.
var scrollableDiv = document.getElementById("scrollTable");
scrollableDiv.scrollTop = scrollableDiv.scrollHeight;
If you want to do this using jQuery, then use the below code.
$("#scrollTable").scrollTop($("#scrollTable")[0].scrollHeight);
If you want to smooth scroll, then try with this.
$('#scrollTable').stop().animate({
scrollTop: $('#scrollTable')[0].scrollHeight
}, 500);
Enjoy, Thanks. :)

Why aren't the table headers using the width setting?

The point of this pen is to have the body of the table scroll without scrolling the header.
That part works, but I can't get the headers to spread out within the Html body to match the data rows. What am I doing wrong?
Thanks, in advance, for the help.
Codepen
body {
margin: 0;
padding: 0;
height: 100vh;
}
div {
background-color: green;
width: 100%;
height: 100%
}
table {
width: 100%;
background-color: red;
height: 100%;
display: flex;
flex-direction: column;
}
thead {
background-color: purple;
width: 100%;
display: block;
}
thead tr {
background-color: orange;
width: 100%;
display: block;
}
;
thead tr td {
min-width: 30%;
width: 30%;
display: inline-block;
}
tbody {
flex: 1;
background-color: blue;
overflow-y: auto;
display: block
}
tbody tr {
background-color: aqua;
width: 100%;
display: block;
}
tbody tr td {
min-width: 30%;
width: 30%;
display: inline-block;
}
<div>
<table>
<thead>
<tr>
<td>Header A</td>
<td>Header B</td>
<td>Header C</td>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
</tbody>
</table>
</div>
screen capture of codepen
Simple syntax error. You have a ; at the end on line 5.
Remove it and enjoy your table.
Use display: flex and justify-content: space-around in your thead tr styles.
body {
margin: 0;
padding: 0;
height: 100vh;
}
div {
background-color: green;
width: 100%;
height: 100%;
}
table {
width: 100%;
background-color: red;
height: 100%;
display: flex;
flex-direction: column;
}
thead {
background-color: purple;
width: 100%;
display: block;
}
thead tr {
background-color: orange;
width: 100%;
overflow: hidden;
display: flex;
justify-content: space-around;
}
thead tr td {
min-width: 30%;
width: 30%;
display: inline-block;
}
tbody {
flex: 1;
background-color: blue;
overflow-y: auto;
display: block;
}
tbody tr {
background-color: aqua;
width: 100%;
display: block;
}
tbody tr td {
min-width: 30%;
width: 30%;
display: inline-block;
}
<html>
<body>
<div>
<table>
<thead>
<tr>
<td>Header A</td>
<td>Header B</td>
<td>Header C</td>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
I've managed to get a simple scrolling table and fixed header, with column width control using display blocked items.
See jsfiddle here http://jsfiddle.net/joshmoto/xjq41yng/4/
table {
width: 100%; /* your table width */
background: blue;
border: 0;
border-spacing: 0;
}
thead,
tbody,
tr,
td,
th {
display: block;
padding: 0;
}
tr:after {
content: ' ';
display: block;
visibility: hidden;
clear: both;
}
thead th {
height: 30px;
background: orange;
}
tbody td {
background: aqua;
}
tbody {
height: 120px; /* fixed tbody height to show scroll example */
overflow-y: auto;
}
tbody td,
thead th {
width: 30%; /* your column width */
float: left;
}
<table>
<thead>
<tr>
<th>Header A</th>
<th>Header B</th>
<th>Header C</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
</tbody>
</table>

How to put a table and a text inside a div?

The code below renders to this:
but I want this:
If I remove <div>hello world</div> the table fit inside the outside div very well.
But I should add the text to the div and hope the text with the table fit well inside the outside div. Can anybody give me any suggestions?
<div style="background-color:green;border:1px solid red;width:81px;height:60px;">
<div>hello world</div>
<div style="height:100%;overflow:auto;background-color:red;opacity:0.4;">
<table>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
</table>
</div>
</div>
Add an overflow:hidden to the wrapper element
<div style="background-color:green;border:1px solid red;width:81px;height:60px;overflow:hidden">
<div>hello world</div>
<div style="height:100%;overflow:auto;background-color:red;opacity:0.4;">
<table>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
</table>
</div>
</div>
Initial answer
You need to add overflow: scroll on the outermost <div>. As this is the one that you gave a fixed height.
<div style="background-color:green;border:1px solid red;width:81px;height:60px;overflow:scroll">
<div>hello world</div>
<div style="background-color:red;opacity:0.4;">
<table>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
</table>
</div>
</div>
Additional answers
Using calc()
Instead of giving the .inner a fixed height of 50px I've opted to calculate the height using calc(100% - 1em). It takes the height of the .outer <div> and subtracts the height of a single line of text. This makes it slightly more maintainable than the 50px version as changing the height of the entire component will now need updating one instead of two numbers.
.outer {
background-color: green;
border: 1px solid red;
width: 81px;
height: 60px;
}
.inner {
background-color: red;
opacity: 0.4;
height: calc(100% - 1em);
overflow: scroll;
}
<div class="outer">
<div>hello world</div>
<div class="inner">
<table>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
</table>
</div>
</div>
Using position: absolute
Another option would be to give the .outer <div> a padding-top and to position the .header on top of the padding-top.
First give your .outer a position: relative to allow the .header's position: absolute to refer to the .outer <div>. Add padding-top: 1em and box-sizing: border-box as you want the height of the .outer to be based on both the content and the padding.
Next add position: absolute and top: 0 to the .header to position it.
The .inner gets height: 100% and a overflow: scroll to let it take up the height of the content of the .outer <div>.
.outer {
position: relative;
box-sizing: border-box;
padding-top: 1em;
background-color: green;
border: 1px solid red;
width: 81px;
height: 60px;
}
.header {
position: absolute;
top: 0;
}
.inner {
height: 100%;
overflow: scroll;
background-color: red;
opacity: 0.4;
}
<div class="outer">
<div class="header">hello world</div>
<div class="inner">
<table>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
</table>
</div>
</div>
1) I have removed the height from 1st div, because it is not necessary there as we are going to scroll the child div
2) in the second div instead of height 100% i have given a height 50px ( you can give any height in px ) as we are going to scroll this div
3) table width 100% will fill the 2nd div
<div style="width: 150px; border: 1px solid rgb(255, 0, 0); background-color: rgb(0, 128, 0);">
<div>hello world</div>
<div style="overflow: auto; background-color: red; opacity: 0.4; height: 50px;">
<table style=" width: 100%;">
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
</tr>
</table>
</div>
</div>

Table headers inside main table header in HTML

How can I achieve this kind of table:
Inside the Schedule column, there are sub columns (Jan, Feb and so on).
I tried <th></th> inside a <th></th>
But it is not working.
See my fiddle: http://jsfiddle.net/TAJzY/1/
The solution is colspan="" and rowspan="":
Use colspan="12" on the "Schedule/Milestone of Activities" cell.
And remove the 12 empty trailing cells in the same <tr> row.
Use rowspan="2" on the "Estimated Budget" cell.
And remove the single empty initial <th> cell from the <tr> below.
Don't forget to use explicit <thead>, <tbody>, and optional <tfoot> sections.
While you can use HTML tables without explicit sections, styling HTML tables with CSS is a lot easier and effective this way, and you can use techniques like thead { position: sticky; } for Excel-style "frozen" rows which are otherwise very difficult - or just tedious - to implement otherwise.
Step 1:
First, make a table, without any splitting/merging of cells, so you have something like this (click the "Run code snippet" button below to see the table):
table { border: 1px outset #bbb; }
table > * > tr > * { border: 1px inset #bbb; }
thead { background-color: #7ACABD; text-align: center; }
tbody { background-color: #e0fffa; }
tfoot { background-color: #39c4ae' }
<table>
<thead>
<tr>
<th>Estimated Budget</th>
<th>Schedule/Milestone of Activities</th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
<tr>
<th></th>
<th>Jan</th>
<th>Feb</th>
<th>Mar</th>
<th>Apr</th>
<th>May</th>
<th>Jun</th>
<th>Jul</th>
<th>Aug</th>
<th>Sep</th>
<th>Oct</th>
<th>Nov</th>
<th>Dec</th>
</tr>
</thead>
<tbody>
<tr>
<td>$123</td>
<td>j</td>
<td>f</td>
<td>m</td>
<td>a</td>
<td>m</td>
<td>j</td>
<td>j</td>
<td>a</td>
<td>s</td>
<td>o</td>
<td>n</td>
<td>d</td>
</tr>
<tr>
<td>$456</td>
<td>j</td>
<td>f</td>
<td>m</td>
<td>a</td>
<td>m</td>
<td>j</td>
<td>j</td>
<td>a</td>
<td>s</td>
<td>o</td>
<td>n</td>
<td>d</td>
</tr>
</tbody>
</table>
Step 2:
Then make the "Schedule/Milestone of Activities" cell span all 12 remaining columns (of the 13 total) with colspan="12" - which also means removing the empty trailing <th></th> elements in the same <tr> as those are now represented by the <th colspan="12"> cell:
table { border: 1px outset #bbb; }
table > * > tr > * { border: 1px inset #bbb; }
thead { background-color: #7ACABD; }
tbody { background-color: #e0fffa; }
tfoot { background-color: #39c4ae' }
<table>
<thead>
<tr>
<th>Estimated Budget</th>
<th colspan="12">Schedule/Milestone of Activities</th>
</tr>
<tr>
<th></th>
<th>Jan</th>
<th>Feb</th>
<th>Mar</th>
<th>Apr</th>
<th>May</th>
<th>Jun</th>
<th>Jul</th>
<th>Aug</th>
<th>Sep</th>
<th>Oct</th>
<th>Nov</th>
<th>Dec</th>
</tr>
</thead>
<tbody>
<tr>
<td>$123</td>
<td>j</td>
<td>f</td>
<td>m</td>
<td>a</td>
<td>m</td>
<td>j</td>
<td>j</td>
<td>a</td>
<td>s</td>
<td>o</td>
<td>n</td>
<td>d</td>
</tr>
<tr>
<td>$456</td>
<td>j</td>
<td>f</td>
<td>m</td>
<td>a</td>
<td>m</td>
<td>j</td>
<td>j</td>
<td>a</td>
<td>s</td>
<td>o</td>
<td>n</td>
<td>d</td>
</tr>
</tbody>
</table>
Step 3:
To make the "Estimated Budget" cell span those 2 rows in <thead> add rowspan="2" and also remove the empty initial <th></th> in the second <tr> (as that empty <th> cell's "slot" is now taken by the <th rowspan="2"> from the previous row).
Like so:
table { border: 1px outset #bbb; }
table > * > tr > * { border: 1px inset #bbb; }
thead { background-color: #7ACABD; }
tbody { background-color: #e0fffa; }
tfoot { background-color: #39c4ae; }
/* Right-align budget numbers in the first column: */
table > tbody > tr > td:first-child { text-align: right; }
<table>
<thead>
<tr>
<th rowspan="2">Estimated Budget</th>
<th colspan="12">Schedule/Milestone of Activities</th>
</tr>
<tr>
<th>Jan</th>
<th>Feb</th>
<th>Mar</th>
<th>Apr</th>
<th>May</th>
<th>Jun</th>
<th>Jul</th>
<th>Aug</th>
<th>Sep</th>
<th>Oct</th>
<th>Nov</th>
<th>Dec</th>
</tr>
</thead>
<tbody>
<tr>
<td>$123</td>
<td>j</td>
<td>f</td>
<td>m</td>
<td>a</td>
<td>m</td>
<td>j</td>
<td>j</td>
<td>a</td>
<td>s</td>
<td>o</td>
<td>n</td>
<td>d</td>
</tr>
<tr>
<td>$456</td>
<td>j</td>
<td>f</td>
<td>m</td>
<td>a</td>
<td>m</td>
<td>j</td>
<td>j</td>
<td>a</td>
<td>s</td>
<td>o</td>
<td>n</td>
<td>d</td>
</tr>
</tbody>
</table>
You use the colspan attribute on the Schedule th. It would make it to span over many columns.
Using rowspan for the Budget th will have the same effect on rows.
Try this (note use of colspan):
<table border="1">
<tr>
<td>budget</td>
<td colspan="3">header</td>
</tr>
<tr>
<td></td>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>a</td>
<td>b</td>
<td>c</td>
<td>d</td>
</tr>
</table>
You can use my http://blocknote.net editor if you need more complex table layout. Table editor there is pretty convenient.
<table>
<tr>
<td>foo</td>
<td colspan="3">Header</td>
</tr>
<tr>
<td></td>
<td>Content</td>
...
</tr>
<tr>
<td>foo1</td>
<td>foo2</td>
...
</tr>
</table>