Petter Hermansen
Petter Hermansen

Reputation: 13

How to place DIVs beside each other

I have several DIVs that I want to place beside each other, but because they are blocking, they fall beneath each other. How can I fix this?

Upvotes: 1

Views: 492

Answers (6)

Liam
Liam

Reputation: 29760

You can achieve this with the following code:

style="display:inline-block";

EDIT

for your edification:http://www.w3schools.com/html/html_styles.asp

Upvotes: 1

Domenic
Domenic

Reputation: 112917

div.i-like-snuggling {
    /* don't ever leave me */
    display: inline-block;
}

Upvotes: 4

Mr Lister
Mr Lister

Reputation: 46609

Or maybe absolute positioning is the best choice for you. We don't know what your HTML looks like!

Upvotes: 1

Bjørn Ove Thue
Bjørn Ove Thue

Reputation: 80

The best way is to use float:left, but in some cases you might use SPAN instead of DIV

Upvotes: 1

Bram
Bram

Reputation: 1112

Your best bet is to go with the css property "float"

div { float: left; width: 200px}

for example. If you don't specify a width, the browser will render a width that it feels appropriate (the width of a child element for example).

I've always found this article a good reference: http://css.maxdesign.com.au/floatutorial/introduction.htm

As suggested by other people, you can also use display:inline-block. It kinda depends on what effect you want to achieve.

Upvotes: 0

csturtz
csturtz

Reputation: 6580

add display: inline-block; style to those divs

Upvotes: 0

Related Questions