Welcome to WebmasterWorld Guest from

Forum Moderators: not2easy

Message Too Old, No Replies

text align with img floating

3:38 pm on Apr 4, 2004 (gmt 0)

10+ Year Member

Is there any way to use CSS to get my text to align to the right when using image float. I have
{ float: left; border: inset 6px #939; margin-right: 10px; }
/* left img float */
{ float: right; border: inset 6px #939; margin-left: 10px; }
/* right img float */
but can not figure out how to get the text on the right float to align right with out doing it in HTML over and over
4:18 pm on Apr 4, 2004 (gmt 0)

10+ Year Member

Have you tried wrapping the text in a div or p and giving it the property of text-align: right;
10:07 pm on Apr 4, 2004 (gmt 0)

10+ Year Member

yep the only way i could get it to work so far is with the html coding <p align="right> tags i was trying to do it thru css so i dont have to code it every where i need it, Thanks
10:34 pm on Apr 4, 2004 (gmt 0)

10+ Year Member

I've been grappling with this one lately. This site had some good info on image captions [simplebits.com].

The best solution I have so far is:

<div class="imgright"> 
<img src=etc. etc.>
<br />
<span>Caption here</span>

This requires a "float:right" for div.imgright, plus whatever formatting you want on the div or the caption (span).

You can use <p> tags for the caption but this won't work nicely under IE 5.2 for Mac. The break/span combination is a bit messy but works best across multiple browsers IMHO.