Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2005
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Text alignment around images

    Hello all. I have two small images within a paragraph and I want the text to start wrapping around the top of last image. For some reason the top line starts at the top of the image, but the lines after that skip down to the bottom of the image and there is a space between the top and bottom.

    Here is my code I am using:
    Code:
    <p style="text-align:left;"><img src="images/packexpo_small.png" align="top" vspace="2">&nbsp;<img src="images/processexpo_small.png" align="top" vspace="2">
    &nbsp;Blah blah blah blah blah blah blah blah blah blah blah blah blah blah Blah blah 
    blah blah blah blah blah blah blah blah blah blah blah blah Blah blah blah blah blah blah 
    blah blah blah blah blah blah blah blah Blah blah blah blah blah blah blah blah blah blah 
    blah blah blah blah Blah blah blah blah blah blah blah blah blah blah blah blah blah blah</p>
    What happens is:

    Image Blah Blah Blah Blah Blah
    Image
    Image
    Image
    Blah Blah Blah Blah Blah Blah Blah Blah.....

    Instead I want it to be:
    Image Blah Blah BLah Blah
    Image Blah Blah Blah Blah
    Image BLah Blah Blah blah
    Blah Blah BLah Blah Blah
    Blah Blah Blah Blah BLah...and so on.

    I've also tried floating the images also but didn't work. I'm having a brain fart today.

    Can anyone help?
    Last edited by Spankinator; 05-11-2007 at 09:14 PM.

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,673
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    You have to float the images for text to go alongside them. Something like this:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    html, body {
    	text-align: center;
    	background: #4d4d4d;
    }
    * {
    	margin: 0;
    	padding: 0;
    	border: none;
    }
    #wrap {
    	width: 300px;
    	margin: 100px auto;
    	background: #CCCCCC;
    }
    .floatLeft {
    	float: left;
    	clear: left;
    }
    </style>
    </head>
    <body>
        <div id="wrap">
            <img src="images/packexpo_small.png" class="floatLeft">
            <img src="images/processexpo_small.png" class="floatLeft">
                <p>
                    &nbsp;Blah blah blah blah blah blah blah blah blah blah blah blah blah blah Blah blah 
                    blah blah blah blah blah blah blah blah blah blah blah blah Blah blah blah blah blah blah 
                    blah blah blah blah blah blah blah blah Blah blah blah blah blah blah blah blah blah blah 
                    blah blah blah blah Blah blah blah blah blah blah blah blah blah blah blah blah blah blah
                </p>
        <!--closes wrap--></div>
    </body>
    </html>
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #3
    Regular Coder croatiankid's Avatar
    Join Date
    Jan 2006
    Posts
    665
    Thanks
    1
    Thanked 12 Times in 12 Posts
    Just wanted to add by saying that it's acting like that because IMG is an inline element, so it's interpereted as part of the text (and as such, can only be on 1 line). By adding float left, you also automatically set it to act as a block level element


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •