Help with CSS

They have: 11 posts

Joined: May 2006

Hi. I would like to ask how can one have two div tags in the same line. At present everytime I create a second div tag(a menu in each div tag) it is going below the first one. Could anyone help me please? Many thanks.

He has: 698 posts

Joined: Jul 2005

To get any two tags in line, use the 'display' selector.

You would have something like this:

div#div1 {
display: inline;
...(other properties)...
}
div#div2 {
display: inline;
...(other properties)...
}
'

Now that I think about it, I'm not 100% sure if it works for DIVs, but it does work for tags like P, LI, etc...

Kurtis

He has: 490 posts

Joined: May 2005

is a block level element, which means it will automatically create a space. You can send one right, and the other left, then line them up with margining. But that's the best you can do as far as I know. Smiling

Of course I am not the foremost expert on this sort of thing.

They have: 11 posts

Joined: May 2006

Can anyone give me a link for a good tutorial about inline with div tags. Thanks

He has: 490 posts

Joined: May 2005

This might help you, take a look.

alistapart.com

They have: 4 posts

Joined: Jul 2006

http://www.mandarindesign.com/boxes.html isn't to bad for some css.

They have: 426 posts

Joined: Feb 2005

you need to float left and right....

#div
{
float: left;
}

He has: 698 posts

Joined: Jul 2005

Yeah, 'display: inline' does not work for DIVs. Here's some sample code that you could use to do it.

The HTML:

<div class="left">
<p>Here's some text...</p>
</div>
<div class="left">
<p>Here's some more text...</p>
</div>
'

The CSS:

div.left {
float: left;
}
'

These would float side by side. You could set one to 'float: right' but this would achieve the same effect by setting an appropriate width and margin. Smiling

Kurtis

They have: 20 posts

Joined: Jul 2006

This should work.

I hope this helps.

Johnny

[edit]
Sorry, didn't see the post with this info already. Smiling
[/edit]

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.