September 15, 201115 yr I've got a div that encloses a photo with text to the left of it. Here's the code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> [ ... ] <div style="width: 500px: margin: auto"> <img src="myimage.jpg" width="200" height="300" style="float: right"> <div style="float: right"> Here is some text that SHOULD appear to the left of the photo. </div> </div> The problem is that the div enclosing the text wants to be at 100% width and therefore positions itself below the image. Now in this very simple code, it's obvious that the width of the div text should be 300px, and by specifying that in the div, I'd solve the problem, but it's not always this obvious. Is there anything I can do that will coerce the text div to nestle itself next to the image? Thanks for any help.
September 15, 201115 yr Delete the float: right for the text div. You've got the correct order with the floated image div first because if the float: right div is first, it should position itself at the top right and then the text div without a float and without a width will move up on the left if there is enough width. <div style="width: 500px: margin: auto"> <img src="myimage.jpg" width="200" height="300" style="float: right"> <div> <p>Here is some text that SHOULD appear to the left of the photo.</p> </div> </div> Edited September 15, 201115 yr by Wickham
September 17, 201115 yr Author Hmm... Apparently I'm not getting my email notifications. Thanks for the help. I'll give that a try.
Create an account or sign in to comment