Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best Way to do Columns in HTML/CSS

Tags:

html

css

I'm looking for a way to display 3 columns of content. I've found a way to display wrap-around columns, but I don't want that for this page. I'm looking for a way to say

<column> <!-- content --> </column> 

3 times, and have 3 columns displayed beside each other. The best example I have offhand is The Verge (http://www.theverge.com/). What is the best way to do this?

like image 384
muttley91 Avatar asked Apr 01 '12 18:04

muttley91


People also ask

How do you make 5 columns in HTML?

First example: create a row ( <div class="row"> ). Then, add the desired number of columns (tags with appropriate . col-*-* classes). The first star (*) represents the responsiveness: sm, md, lg, xl or xxl, while the second star represents a number, which should add up to 12 for each row.

How do I display 3 columns in HTML?

Simply create a <div> element inside your HTML document, and by using this syntax, you are going to divide the content into three columns.


1 Answers

I would suggest you to either use <table> or CSS.

CSS is preferred for being more flexible. An example would be:

<!-- of course, you should move the inline CSS style to your stylesheet --> <!-- main container, width = 70% of page, centered --> <div id="contentBox" style="margin:0px auto; width:70%">   <!-- columns divs, float left, no margin so there is no space between column, width=1/3 -->     <div id="column1" style="float:left; margin:0; width:33%;">      CONTENT     </div>      <div id="column2" style="float:left; margin:0;width:33%;">      CONTENT     </div>      <div id="column3" style="float:left; margin:0;width:33%">      CONTENT     </div> </div> 

jsFiddle: http://jsfiddle.net/ndhqM/

Using float:left would make 3 columns stick to each other, coming in from left inside the centered div "content box".

like image 127
AbSoLution8 Avatar answered Oct 19 '22 14:10

AbSoLution8