I want to move columns to the left and also there should be set a fixed size in between.
Now it looks like this:
Hopefully I could get this result:
CSS Code:
.table {
width:100%;
}
.table table{
border-collapse: collapse;
width:100%;
}
.table td{
padding-left: 5px;
color: #000000;
font-size: 12px;
line-height: 16px;
margin-bottom: 6px;
font-family: Arial,Helvetica,sans-serif;
}
.table tr:nth-child(odd){ background-color:#EFEFEF; }
.table tr:nth-child(even) { background-color:#ffffff; }
.table tr:first-child td{
padding-left: 5px;
background-color:#EFEFEF;
text-align:left;
color:#868686;
font-size: 12px;
font-family: Arial,Helvetica,sans-serif;
line-height: 16px;
margin-bottom: 6px;
}
/* Border line in the middle (first-child) Example: 1 | 2 | 3 */
.table tr:first-child td:not(:last-child) { border-right: 1px solid #868686;}
HTML:
<div class="table" >
<table>
<tr>
<td>
ID#
</td>
<td>
Name
</td>
<td>
Edit
</td>
<td>
Delete
</td>
</tr>
<tr><td><?php echo $tags_id ?></td><td><?php echo $name ?></td> <td><?php echo "<a href='edit.php?id=$tags_id'>Edit</a>"; ?></td> <td><?php echo "<a href='delete.php?id=$tags_id'>Delete</a>"; ?></td></tr>
</table>
</div>
You didn't tell us what version of HTML you are using, but the following should work in any version. Add a <colgroup> as the first child of your table element like this:
<table>
<colgroup>
<col width="20em"/>
<col width="10em"/>
<col width="10em"/>
</colgroup>
</table>
This will fix the widths of the columns to a certain number of characters. If this doesn't work out the way you want it to, try setting a width attribute on the <table> and use percentages in your <col/> widths:
<table width="40%">
<colgroup>
<col width="50%"/>
<col width="25%"/>
<col width="25%"/>
</colgroup>
</table>
You've setup the width:100% to your table that means all the column will try to span across all the available width. So you can remove that from your table
Js Fiddle Demo
Try like this: Demo
.table {
width:100%;
}
.table table {
border-collapse: collapse;
width:100%;
}
.table tr {
clear:both;
}
.table tbody td, .table th {
display:inline;
width:auto;
text-align:left;
padding: 1px 10px;
color: #000000;
font-size: 12px;
line-height: 16px;
margin-bottom: 6px;
font-family: Arial, Helvetica, sans-serif;
}
.table tbody tr:nth-child(odd) {
background-color:#ffffff;
}
.table tbody tr:nth-child(even) {
background-color:#EFEFEF;
}
.table thead tr {
background-color:#EFEFEF;
}
.table thead tr th {
color:#868686;
border-right: 1px solid #868686;
}
HTML:
<div class="table">
<table>
<thead>
<tr>
<th>ID#</th>
<th>Name</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<tr>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr>
<tr>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr>
<tr>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr>
</tbody>
</table>
</div>
Hope this helps you!
.table {
width:50%;
}
This should solve the issue. Here is a fiddle.
http://jsfiddle.net/xzzcrouf/3/. You can also try this for better styling -
http://jsfiddle.net/xzzcrouf/4/
I removed width:100% from my table in CSS.
HTML:
<div class="table" >
<table>
<colgroup>
<col style="width:50px">
<col style="width:250px">
<col style="width:180px">
<col style="width:1500px">
</colgroup>
<tr>
<td>ID#</td>
<td>Name</td>
<td>Edit</td>
<td>Delete</td>
</tr>
<tr>
<td>1</td>
<td>NAME</td>
<td>EDIT</td>
<td>DELETE</td>
</tr>
</table>
</div>
Js Fiddle Demo
Maybe there is a better way but it's displayed as I wanted.
Thanks #pgoetz for sharing the information about colgroup.
Related
Current HTML:
<section class="Product-Info">
<table>
<tr>
<th colspan="2">Product Infromation</th>
</tr>
<tr>
<th>Product Name:</th>
<td>Name</td>
</tr>
<tr>
<th>Product Description:</th>
<td>Description</td>
</tr>
</table>
</section>
Desired:
Question:
How can I add borders and width to my current HTML with CSS as the desired outcome?
What I have tried
I have tried the following css:
table {
border: 1px solid black;
}
This just puts a border around the table. How can I add it same as desired too?
table {
border-collapse: collapse;
/* if you don't add this line you will see "double" borders */
border: 1px solid black;
width: 100vw;
}
th{
color: white;
background-color: blue;
}
td{
background-color: white;
width: 70%;
}
td, th {
border: 1px solid black;
}
<section class="Product-Info">
<table>
<tr>
<th colspan="2">Product Infromation</th>
</tr>
<tr>
<th>Product Name:</th>
<td>Name</td>
</tr>
<tr>
<th>Product Description:</th>
<td>Description</td>
</tr>
</table>
</section>
Heres, your snippet!
simply this:
table {
border-collapse: collapse; /* if you don't add this line you will see "double" borders */
border: 1px solid black;
}
table th,
table td {
text-align: left;
border: 1px solid black;
}
demo here https://jsfiddle.net/3hpks1mL/
hope it help you
section {
width:100wh;
}
table{
width:100%
}
<section class="Product-Info">
<table border="1">
<tr>
<th colspan="2">Product Infromation</th>
</tr>
<tr>
<td>Product Name:</td>
<td >Name</td>
</tr>
<tr>
<td > Product Description:</td>
<td >Description</td>
</tr>
</table>
</section>
Fairly easy, in your example you just have to apply the desired background colour to the table header cells (th), like so:
th {
background: darkblue;
color: white; /* Assuming you don't want black text on dark blue. */
}
For the standard border around the table cells to disappear you have to simply collapse the border on the main table element, like so:
table {
border-collapse: collapse;
}
With that set you can now apply any border styling you want to your table, in any thickness, colour and style you want.
I'd go with the following:
table, th, td {
border: 1px solid black;
}
.Product-Info > table {
width: 100%;
table-layout: fixed;
border-collapse: collapse;
text-align: center;
}
.Product-Info tr > *:first-child {
background: blue;
color: white;
text-align: left;
}
.w-25 {
width: 25% !important;
max-width: 25% !important;
}
.text-center {
text-align: center !important;
}
<section class="Product-Info">
<table>
<colgroup>
<col class="w-25 blue">
<col class="">
</colgroup>
<tr>
<th colspan="2" class="text-center">Product Infromation</th>
</tr>
<tr>
<th class="text-left">Product Name:</th>
<td class="text-center">Name</td>
</tr>
<tr>
<th class="text-left">Product Description:</th>
<td class="text-center">Description</td>
</tr>
</table>
</section>
Extra information (The "copy-paste" snippet under #Random-COSMOS answer).
Table is block-level element
"A block-level element always starts on a new line and takes up the
full width available. https://www.w3schools.com/html/html_blocks.asp"
Set any width you want to the table (400px or 30%) ==> 100% in your case (100% of its parent).
<table style="width: 100%;">
To specify table borders in CSS, use the border property.
table, th, td {
border: 1px solid black;
}
Out of topic - Accessible tables
For Web Accessibility => Add relationship between header and data cells (scope="row" / scope="col").
Full article: https://www.w3.org/WAI/tutorials/tables/two-headers/
<table>
<tr>
<th scope="col" colspan="2">Product Infromation</th>
</tr>
<tr>
<th scope="row">Product Name:</th>
<td>Some Name</td>
</tr>
<tr>
<th scope="row">Product Description:</th>
<td>Some Description</td>
</tr>
</table>
Here is html and CSS code:
table,th,td{
border:1px solid blue;
border-collapse:collapse;
}
td{
text-align:center;
}
td{padding:10px;
color:#cc7722;
}
table{
border-spacing:5px;
background-color:yellowgreen;
font-weight:bold;
width:100%
}
#hello{
color:red;
}
.hi{
background-color:blue;
}
<table>
<caption id="hello">Employee Data</caption>
<tr>
<div class="hi">
<th>Employee Name</th>
<th>
Department
</th>
<th>Salary</th>
</div>
</tr>
<tr>
<td>Vaibhav</td>
<td>CSE</td>
<td>10000</td>
</tr>
</table>
Output
Here background color blue for class hi not shown
so what can be the reason
and what is the possible solution for this
If you use div as anything other than a cell value, you'll get misbehaving browsers.
Wrap your header row definition around the thead tag and style that instead. Don't forget to then wrap the body around tbody.
table,
th,
td {
border: 1px solid blue;
border-collapse: collapse;
}
td {
text-align: center;
}
td {
padding: 10px;
color: #cc7722;
}
table {
border-spacing: 5px;
background-color: yellowgreen;
font-weight: bold;
width: 100%
}
#hello {
color: red;
}
.hi {
background-color: blue;
}
<table>
<caption id="hello">Employee Data</caption>
<thead class="hi">
<tr>
<th>Employee Name</th>
<th>
Department
</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td>Vaibhav</td>
<td>CSE</td>
<td>10000</td>
</tr>
</tbody>
</table>
you can't use a div within a table for styling. just apply the class to the tr itself
html
<table>
<caption id="hello">Employee Data</caption>
<tr class="hi">
<th>Employee Name</th>
<th>Department</th>
<th>Salary</th>
</tr>
<tr>
<td>Vaibhav</td>
<td>CSE</td>
<td>10000</td>
</tr>
</table>
Your table shouldn't have a div inside, instead you have to do like this:
<tr class="hi">
add div inside th,td it'll work not outside
table,th,td{
border:1px solid blue;
border-collapse:collapse;
}
td{
text-align:center;
}
td{padding:10px;
color:#cc7722;
}
table{
border-spacing:5px;
background-color:yellowgreen;
font-weight:bold;
width:100%
}
#hello{
color:red;
}
.hi{
background-color:blue;
}
<table>
<caption id="hello">Employee Data</caption>
<tr>
<th>Employee Name</th>
<th>
Department
</th>
<th>Salary</th>
</div>
</tr>
<tr>
<td><div class="hi">Vaibhav</div></td>
<td>CSE</td>
<td>10000</td>
</tr>
</table>
I think what you want to do is changing the <tr> background, which you can easily accomplish by removing your <div> and giving the class to your <tr> tag. As the following:
<table>
<caption id="hello">Employee Data</caption>
<tr class="hi">
<th>Employee Name</th>
<th>Department</th>
<th>Salary</th>
</tr>
<tr>
<td>Vaibhav</td>
<td>CSE</td>
<td>10000</td>
</tr>
</table>
And your CSS is just the same.
table,th,td{
border:1px solid blue;
border-collapse:collapse;
}
td{
text-align:center;
}
td{padding:10px;
color:#cc7722;
}
table{
border-spacing:5px;
background-color:yellowgreen;
font-weight:bold;
width:100%
}
#hello{
color:red;
}
.hi{
background-color:blue;
}
Does moving the class to the th accomplish what you are wanting?
table,th,td{
border:1px solid blue;
border-collapse:collapse;
}
td{
text-align:center;
}
td{padding:10px;
color:#cc7722;
}
table{
border-spacing:5px;
background-color:yellowgreen;
font-weight:bold;
width:100%
}
#hello{
color:red;
}
.hi{
background-color:blue;
}
<table>
<caption id="hello">Employee Data</caption>
<tr class="hi">
<th >Employee Name</th>
<th>
Department
</th>
<th>Salary</th>
</tr>
<tr>
<td>Vaibhav</td>
<td>CSE</td>
<td>10000</td>
</tr>
</table>
If possible to change html then You can use combination of thead, tbody to set different colors to table head and body.
Example
<style>
thead {color:green;}
tbody {background:blue;}
tfoot {color:red;}
table, th, td {
border: 1px solid black;
}
</style>
<table>
<thead>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
</thead>
<tfoot>
<tr>
<td>Sum</td>
<td>$180</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</tbody>
</table>
All tr in tbody will have background blue.
Otherwise you have to use styling for tr, th separately
I have a table like this:
<table>
<thead>
<tr>
<th>Name</th>
<th>Phone no.</th>
<th>Address</th>
<th>Wealth</th>
</tr>
</thead>
<tbody>
<tr>
<th>John Doe</th>
<td>00123456789</td>
<td>Morgue St. 21</td>
<td>$100,000</td>
</tr><tr>
<th>Mary Sue</th>
<td>00987654321</td>
<td>Impossible St. 12</td>
<td>$999,999,999,999,999</td>
</tr><tr>
<th>Cpt. Kirk</th>
<td>00999999999</td>
<td>Enterprise St. 22</td>
<td>$100,000,000</td>
</tr>
</tbody>
</table>
Well, this table is pretty wide. And now I have to make a stylesheet that would make the site appropriate for viewing on a narrow screen, like a mobile phone. So I have to do sth with this wide table.
I was thinking if this table could display vertically, not horizontally. More specifically, I was thinking if it could display more like this:
<ul>
<li><strong>John Doe:</strong>
<ul>
<li><em>Phone no.:</em> 00123456789</li>
<li><em>Address:</em> Morgue St. 21</li>
<li><em>Wealth:</em> $100,000</li>
</ul>
</li><li><strong>Mary Sue:</strong>
<ul>
<li><em>Phone no.:</em> 00987654321</li>
<li><em>Address:</em> Impossible St. 12</li>
<li><em>Wealth:</em> $999,999,999,999,999</li>
</ul>
</li><li><strong>Cpt. Kirk:</strong>
<ul>
<li><em>Phone no.:</em> 00999999999</li>
<li><em>Address:</em> Enterprise St. 22</li>
<li><em>Wealth:</em> $100,000,000 </li>
</ul>
</li>
</ul>
Now, I surely could make a Javascript that would transform the table code from the first snippet to the list code from the second snippet. But I wonder, if this is necessary? Is it possible to make a CSS stylesheet that, when attached to the table code from the first snippet would make it look like the second snippet?
Sure, you can play with media queries and change the display of the table :
See this fiddle
#media(max-width: 640px){
table, table td, table tr, table th { display: block; text-align: left; }
table th, table td { margin: 0; padding-left: 25px; }
table td { margin-left: 40px;list-style: square; display: list-item; padding-left: 0; }
table thead { display: none; }
}
td, th {
text-align: left;
display: block;
float: left;
width: 100%;
}
thead {
display: none;
}
<table>
<thead>
<tr>
<th>Name</th>
<th>Phone no.</th>
<th>Address</th>
<th>Wealth</th>
</tr>
</thead>
<tbody>
<tr>
<th>John Doe</th>
<td>00123456789</td>
<td>Morgue St. 21</td>
<td>$100,000</td>
</tr><tr>
<th>Mary Sue</th>
<td>00987654321</td>
<td>Impossible St. 12</td>
<td>$999,999,999,999,999</td>
</tr><tr>
<th>Cpt. Kirk</th>
<td>00999999999</td>
<td>Enterprise St. 22</td>
<td>$100,000,000</td>
</tr>
</tbody>
</table>
Here's a possible way without the <thead> elements, but you could create hidden elements before each person, e.g. <span class="hidden">Name:</span> Cpt. Kirk and then enable all the hidden elements with media queries. Not the most elegant solution, I'd probably prefer JS for this.
There might be better ways to do this, but here is a solution to reach the goal:
table thead{
display:none;
}
table tbody tr th{
display:block;
text-align: left;
}
table tbody tr td{
display:block;
margin-left:20px;
}
table tbody tr th::before{
content:"• ";
}
table tbody tr td::before{
content:"◊ ";
}
Find a working example: https://jsfiddle.net/ktnurvfr/
You can change the table elements to display block and force them to act like block elements just add this class to your table.
.vertical-table thead{
display:none;
}
.vertical-table tr, .vertical-table th, .vertical-table td{
display:block;
width:100%;
}
.vertical-table thead{
display:none;
}
.vertical-table tr, .vertical-table th, .vertical-table td{
display:block;
width:100%;
}
<table class="vertical-table">
<thead>
<tr>
<th>Name</th>
<th>Phone no.</th>
<th>Address</th>
<th>Wealth</th>
</tr>
</thead>
<tbody>
<tr>
<th>John Doe</th>
<td>00123456789</td>
<td>Morgue St. 21</td>
<td>$100,000</td>
</tr><tr>
<th>Mary Sue</th>
<td>00987654321</td>
<td>Impossible St. 12</td>
<td>$999,999,999,999,999</td>
</tr><tr>
<th>Cpt. Kirk</th>
<td>00999999999</td>
<td>Enterprise St. 22</td>
<td>$100,000,000</td>
</tr>
</tbody>
</table>
you can use this code :
#media(max-width: 640px){
table, table td, table tr, table th { display: block; text-align: left; }
table th, table td { margin: 0; padding-left: 25px; }
table td { margin-left: 40px;list-style: square; display: list-item; padding-left: 0; }
table thead { display: none; }
}
i will be work.
I had the same problem. During my search I encountered this elegant solution by sergiopinnaprato: http://bootsnipp.com/snippets/featured/no-more-tables-respsonsive-table
On smaller screens it changes the table to a single column. Very readable solution using only html and css code:
HTML:
<div id="no-more-tables">
<table class="col-md-12 table-bordered table-striped table-condensed cf">
<thead class="cf">
<tr>
<th>Code</th>
<th>Company</th>
<th class="numeric">Price</th>
<th class="numeric">Change</th>
<th class="numeric">Change %</th>
<th class="numeric">Open</th>
<th class="numeric">High</th>
<th class="numeric">Low</th>
<th class="numeric">Volume</th>
</tr>
</thead>
<tbody>
<tr>
<td data-title="Code">AAC</td>
<td data-title="Company">AUSTRALIAN AGRICULTURAL COMPANY LIMITED.</td>
<td data-title="Price" class="numeric">$1.38</td>
<td data-title="Change" class="numeric">-0.01</td>
<td data-title="Change %" class="numeric">-0.36%</td>
<td data-title="Open" class="numeric">$1.39</td>
<td data-title="High" class="numeric">$1.39</td>
<td data-title="Low" class="numeric">$1.38</td>
<td data-title="Volume" class="numeric">9,395</td>
</tr>
<tr>
<td data-title="Code">AAD</td>
<td data-title="Company">ARDENT LEISURE GROUP</td>
<td data-title="Price" class="numeric">$1.15</td>
<td data-title="Change" class="numeric">+0.02</td>
<td data-title="Change %" class="numeric">1.32%</td>
<td data-title="Open" class="numeric">$1.14</td>
<td data-title="High" class="numeric">$1.15</td>
<td data-title="Low" class="numeric">$1.13</td>
<td data-title="Volume" class="numeric">56,431</td>
</tr>
</tbody>
</table>
</div>
CSS:
#media only screen and (max-width: 800px) {
/* Force table to not be like tables anymore */
#no-more-tables table,
#no-more-tables thead,
#no-more-tables tbody,
#no-more-tables th,
#no-more-tables td,
#no-more-tables tr {
display: block;
}
/* Hide table headers (but not display: none;, for accessibility) */
#no-more-tables thead tr {
position: absolute;
top: -9999px;
left: -9999px;
}
#no-more-tables tr { border: 1px solid #ccc; }
#no-more-tables td {
/* Behave like a "row" */
border: none;
border-bottom: 1px solid #eee;
position: relative;
padding-left: 50%;
white-space: normal;
text-align:left;
}
#no-more-tables td:before {
/* Now like a table header */
position: absolute;
/* Top/left values mimic padding */
top: 6px;
left: 6px;
width: 45%;
padding-right: 10px;
white-space: nowrap;
text-align:left;
font-weight: bold;
}
/*
Label the data
*/
#no-more-tables td:before { content: attr(data-title); }
}
Hope this helps!
I want to have a fixed width for my editable table, but I also wanting to set different width for each TD.
In my attempt I am able to get the table set at a fixed width, but this causes the width of the TDs appear to be 50% instead of the 80% - 20% I had before setting the fixed width
CSS
table {
margin: 15px 0;
border: 1px solid black;
table-layout: fixed;
width: 100%;
}
.fixed td:nth-of-type(1) {width:20%;}
.fixed td:nth-of-type(2) {width:80%; text-align: left;}
.fixed {
margin:0px;padding:0px;
width:100%;
border:1px solid #000; }
.fixed td {
margin:0px;padding:0px;
width:100%;
border:1px solid #000; }
HTML
<div class="fixed" contenteditable="true">
<table>
<tbody>
<tr>
<td colspan="2">Header:</td>
</tr>
<tr>
<td>Name:</td>
<td><br/></td>
</tr>
<tr>
<td>DOB::</td>
<td><br/></td>
</tr>
<tr>
<td>Comments:</td>
<td><br/></td>
</tr>
</table>
What am I missing? Check this Fiddle if it will help. Try it out by typing enough to see it automatically goes to the next line after a certain point.
The problem with your code is that your first <tr> is having colspan="2". So when you give a width:100% to all the TDs of the table, the css won't get applied to the underlying TDs as you want.
Your solution is to separate the Header td: <td colspan="2">Header:</td> into a separate table (Refer HTML-1 below)
or
put the underlying TDs in the same TR as that of the header (Refer HTML-2 below).
Also change the CSS and simplify it like I did below. you have written a lot of unnecessary CSS.
Working Fiddle Here
Here's what I tried. try this:
HTML-1:
<table class="fixed" >
<tbody>
<tr>
<td colspan="2">Header:</td>
</tr>
</tbody>
</table>
<table class="fixed" >
<tbody>
<tr>
<td>Name:</td>
<td>test</td>
</tr>
<tr>
<td>DOB::</td>
<td>tes</td>
</tr>
<tr>
<td>Comments:</td>
<td>test</td>
</tr>
</table>
HTML-2:
<table class="fixed" >
<tbody>
<tr>
<td colspan="2">Header:</td>
<tr>
<td>Name:</td>
<td>test</td>
</tr>
<tr>
<td>DOB::</td>
<td>tes</td>
</tr>
<tr>
<td>Comments:</td>
<td>test</td>
</tr>
</tr>
</tbody>
</table>
Simplified CSS:
table {
margin: 0 0;
width: 100%;
table-layout: fixed;
}
.fixed td:nth-of-type(1) {width:80%;}
.fixed td:nth-of-type(2) {width:20%; text-align: left;}
.fixed td {
margin:0px;padding:0px;
border:1px solid #000; }
You have Errors in your html syntax although that is nothing to do with the problem.
See if you need something like this fiddle.
table {
margin: 15px 0;
border: 1px solid black;
width: 100%;
}
.fixed td:nth-of-type(1) {width:20%;}
.fixed td:nth-of-type(2) {width:80%; text-align: left;}
.fixed {
margin:0px;padding:0px;
width:100%;
border:1px solid #000; }
.fixed td {
margin:0px;padding:0px;
width:100%;
border:1px solid #000; }
<div class="fixed" contenteditable="true">
<table>
<tbody>
<tr>
<td colspan="2">Header:</td>
</tr>
<tr>
<td>Name:</td>
<td><br/></td>
</tr>
<tr>
<td>DOB::</td>
<td><br/></td>
</tr>
<tr>
<td>Comments:</td>
<td><br/></td>
</tr>
</tbody>
</table></div>
otherwise you wont be able to achieve variable td width as all the td will have same width in a column.
you can use colspan attribute for a workaround.
I have a table like this
<table>
<thead>
<tr>
<th>Numbers</th>
<th>Alphabet</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>a</td>
</tr>
<tr>
<td>2</td>
<td>b</td>
</tr>
</tbody>
</table>
Normally, the first column will show Number 1 2(top to bottom) and the second column is Alphabet a b
Now, I'd like to convert <thead> to vertical and <tbody> <tr> to vertical so that Number 1 2 will be in a horizontal line and Alphabet a b will be in another horizontal one.
CSS
thead {
float: left;
}
thead th {
display: block;
}
tbody {
float: right;
}
The thead turns to vertical, but tbody tr doesn't.
Does anyone know how to get it work?
THANKS
Not sure why just don't change the table layout, but I guess you have your reasons.
Anyway this was not an easy one :)
Here's the CSS code
table{
display:block;
padding: 0px;
border-collapse:collapse;
border-spacing:0;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
}
thead{
display: block;
float: left;
margin: 0px;
padding: 0px;
width: 100px;
}
tbody{
margin: 0px;
padding: 0px;
}
tbody tr {
float:left;
}
th, td{
display:block;
padding: 5px;
margin: 0px;
}
thead > tr th:nth-child(odd) {
display:block;
float:left;
}
thead > tr th:nth-child(even) {
display:block;
float:left;
}
tbody > tr td:nth-child(odd) {
display:block;
}
tbody > tr td:nth-child(even) {
display:block;
float:right;
}
and here's the demo with yout HTML table structure:
http://jsfiddle.net/darkosss/83kVc/
Hope this helps
why dont you use this kind of structure if your table table is not going to change dynamically.
<table>
<tr>
<th>Numbers</th>
<td>1</td>
<td>1</td>
</tr>
<tr>
<th>Alphabet</th>
<td>a</td>
<td>a</td>
</tr>
</table>
My friend, in this condition, don't use thead and tbody. Do like this,
<table>
<tr>
<th>Numbers</th>
<td>1</td>
<td>2</td>
</tr>
<tr>
<th>Alphabet</th>
<td>a</td>
<td>b</td>
</tr>
</table>