468,484 Members | 1,572 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,484 developers. It's quick & easy.

Image and Div side by side

Hello,

I have a container div and inside it I have an image and another div
which I want to place side by side:

<div id="container">
<img id="image"/>
<div id="content">
</div>

Is it possible to float the image left and the div right and make them
side by side with CSS?

I know how to do this by placing the image inside another div but I
would like to avoid that.

Thanks,
Miguel

Dec 22 '06 #1
2 9422
Scripsit shapper:
<div id="container">
<img id="image"/>
<div id="content">
</div>
You should have posted a URL and not a fragment of HTML, which isn't even
what you've really got (you hardly have that badly invalid markup).
Is it possible to float the image left and the div right and make them
side by side with CSS?
Yes. What's the problem with that? You need to set the width for the div, of
course. And if they are just floated that way, they might appear rather far
from each other, but that's really what you asking for.

Or maybe you actually want them to appear _near_ to each other, on the left.
Then float both of them left (and set some reasonable margin between them).
I know how to do this by placing the image inside another div but I
would like to avoid that.
Why would you avoid that, and what have you really done? Telling the URL
might reveal what the desired appearance really is.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Dec 22 '06 #2
shapper wrote:
Hello,

I have a container div and inside it I have an image and another div
which I want to place side by side:

<div id="container">
<img id="image"/>
<div id="content">
</div>

Is it possible to float the image left and the div right and make them
side by side with CSS?
Yes, but depending on what you want to do and on dimension requirements,
you may not need to float the div at all since the div will
automatically flow to the right of the image.
I know how to do this by placing the image inside another div but I
would like to avoid that.
I don't understand why you would want to do that. You can float the
image directly without placing it into a div.

--
Gus
Dec 23 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Stanimir Stamenkov | last post: by
1 post views Thread by Hardy Wang | last post: by
9 posts views Thread by zacariaz | last post: by
3 posts views Thread by jackiepatti | last post: by
9 posts views Thread by shapper | last post: by
6 posts views Thread by nuhura01 | last post: by
32 posts views Thread by C. (http://symcbean.blogspot.com/) | last post: by
2 posts views Thread by gieforce | last post: by
reply views Thread by theflame83 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.