...

View Full Version : Text alignment around images



Spankinator
05-11-2007, 09:11 PM
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:

<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?

Excavator
05-11-2007, 09:27 PM
You have to float the images for text to go alongside them. Something like this:



<!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>

croatiankid
05-11-2007, 09:30 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum