I'm looking for a super easy method to create a two column format to display some data on a webpage. How can i achieve the same format as:
<table> <tr> <td>AAA</td> <td>BBB</td> </tr> </table>
I'm open to HTML5 / CSS3 techniques as well.
Make sure that the sum of the colum-widths equals the wrap width. Alternatively you can use percentage values for the width as well. Actually, you don't really need to float anything to the right, both divs can have the float to the left and the effect is the same as what was request by the OP.
To merge table columns in HTML use the colspan attribute in <td> tag. With this, merge cells with each other. For example, if your table is having 4 rows and 4 columns, then with colspan attribute, you can easily merge 2 or even 3 of the table cells.
The below table gives you the relation between a 'table' tag and the corresponding supported CSS property to represent the same element. So, when creating a table, all you need to do is, instead of the HTML 'table' tag, merely use the 'div' tag and add the corresponding CSS to display a table.
In Word 2007, click the Page Layout tab, choose Breaks in the Page Setup section, and click Continuous in the drop-down menu. In Word 2003, click Format > Columns and choose the two-column icon under Presets. In Word 2007, click the Page Layout tab on the ribbon and click Columns > Two.
<style type="text/css"> #wrap { width:600px; margin:0 auto; } #left_col { float:left; width:300px; } #right_col { float:right; width:300px; } </style> <div id="wrap"> <div id="left_col"> ... </div> <div id="right_col"> ... </div> </div>
Make sure that the sum of the colum-widths equals the wrap width. Alternatively you can use percentage values for the width as well.
For more info on basic layout techniques using CSS have a look at this tutorial
Well, you can do css tables instead of html tables. This keeps your html semantically correct, but allows you to use tables for layout purposes.
This seems to make more sense than using float hacks.
#content-wrapper{ display:table; } #content{ display:table-row; } #content>div{ display:table-cell } /*adding some extras for demo purposes*/ #content-wrapper{ width:100%; height:100%; top:0px; left:0px; position:absolute; } #nav{ width:100px; background:yellow; } #body{ background:blue; }
<div id="content-wrapper"> <div id="content"> <div id="nav"> Left hand content </div> <div id="body"> Right hand content </div> </div> </div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With