![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, What is the best way to place an image and a text side by side using CSS? Basicaly what I am trying to do is to make the image and the text to appear as follows: Image My Text... XXXXX --------------- XXXXX --------------- --------------- --------------- Do you understand? Like to table columns. However, I was looking to do this without a table. |
#3
| |||
| |||
|
|
On 2006-09-27, shapper <mdmoura (AT) gmail (DOT) com> wrote: What is the best way to place an image and a text side by side using CSS? ... Like to table columns. However, I was looking to do this without a table. Put the text in a <div> or something, and make both the image and div float: left. Put the <img> immediately before the <div> in the source: |
#4
| |||
| |||
|
|
In article <slrnehl7ck.qh9.spamspam (AT) bowser (DOT) marioworld>, Ben C <spamspam (AT) spam (DOT) eggs> wrote: On 2006-09-27, shapper <mdmoura (AT) gmail (DOT) com> wrote: What is the best way to place an image and a text side by side using CSS? ... Like to table columns. However, I was looking to do this without a table. Put the text in a <div> or something, and make both the image and div float: left. Put the <img> immediately before the <div> in the source: Won't that cause the text to flow around the image underneath, if the text is long enough? |
|
If the OP actually wants columns, then I have found that the best, most reliable, most browser-compatible way to make columns is to use side-by-side table cells. [...] |
#5
| |||
| |||
|
|
On 2006-09-27, axlq <axlq (AT) spamcop (DOT) net> wrote: In article <slrnehl7ck.qh9.spamspam (AT) bowser (DOT) marioworld>, Ben C <spamspam (AT) spam (DOT) eggs> wrote: On 2006-09-27, shapper <mdmoura (AT) gmail (DOT) com> wrote: What is the best way to place an image and a text side by side using CSS? ... Like to table columns. However, I was looking to do this without a table. Put the text in a <div> or something, and make both the image and div float: left. Put the <img> immediately before the <div> in the source: Won't that cause the text to flow around the image underneath, if the text is long enough? No, because the text is in a floating box of its own. They both float around any other inline stuff that might be in the containing box, in this case nothing. If the OP actually wants columns, then I have found that the best, most reliable, most browser-compatible way to make columns is to use side-by-side table cells. [...] You're probably right. |
#6
| |||
| |||
|
|
Put the text in a <div> or something, and make both the image and div float: left. Put the <img> immediately before the <div> in the source: Won't that cause the text to flow around the image underneath, if the text is long enough? No, because the text is in a floating box of its own. They both float around any other inline stuff that might be in the containing box, in this case nothing. |
#7
| |||
| |||
|
|
Tables should always be used for tabular data only - not for presentation or layout purposes. |
|
Let's say the image is 200 pixels wide: img style="float:left" / div style="margin-left: 220px;" Text goes here /div That should be all you need. |
#8
| |||
| |||
|
|
In article <slrnehl996.qh9.spamspam (AT) bowser (DOT) marioworld>, Ben C <spamspam (AT) spam (DOT) eggs> wrote: Put the text in a <div> or something, and make both the image and div float: left. Put the <img> immediately before the <div> in the source: Won't that cause the text to flow around the image underneath, if the text is long enough? No, because the text is in a floating box of its own. They both float around any other inline stuff that might be in the containing box, in this case nothing. Except the columnar aspect would get lost if the browser window is narrowed too far, when one box wraps under the other, no? |
|
I guess you could put both boxes in a no-wrap container. |
#9
| ||||
| ||||
|
|
No, that's not columnar presentation. |
|
The text will wrap under the image. |
|
It's not as straightforward as a table, and you end up with just about as many markup elements. img style="float:left" / div style="margin-left: 220px;" /div |
|
In article <1159448501.873388.121850 (AT) m73g2000cwd (DOT) googlegroups.com>, matthom (AT) gmail (DOT) com <matthom (AT) gmail (DOT) com> wrote: Tables should always be used for tabular data only - not for presentation or layout purposes. This mantra gets repeated a lot, and while the intention is good, the problems with it are well known, so I won't restart the argument again here. Let's say the image is 200 pixels wide: img style="float:left" / div style="margin-left: 220px;" Text goes here /div That should be all you need. No, that's not columnar presentation. The text will wrap under the image. Try doing it in CSS in such a way that always preserves the side-by-side relationship. It's not as straightforward as a table, and you end up with just about as many markup elements. In this case, there's not much semantic difference between <div> and <td>. -A |
#10
| |||
| |||
|
|
A table is not meant for layout - use CSS - it allows for much more control |
![]() |
| Thread Tools | |
| Display Modes | |
| |