HTML 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">
#topcontent {
border:1px solid #ccc;;
}
#topcontent p {margin:0}
#topcontent img {
float:left;
width:280px;
margin:0 7px 0 15px;
}
.clearfix:after {
content:".";
display:block;
height:0;
clear:both;
visibility:hidden;
}
.clearfix {
display:inline-block;
}
</style>
<!--[if lt IE 7]>
<style type="text/css">
/* \ */
* html .clearfix {height: 1%;}
.clearfix {display: block;}
/* / */
</style>
<![endif]-->
</head>
<body>
<div id="topcontent">
<p class="clearfix"><img src="image.gif" width="280" height="150" title="" alt="" />Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque ornare metus. Duis at felis. Vestibulum nibh. Phasellus dictum tortor in mi placerat scelerisque. Donec blandit turpis ac quam. Nullam nisi. Maecenas odio odio, dignissim eget, tincidunt sollicitudin, commodo ac, odio. Cras pharetra, ante ac dignissim porta, mauris ante vestibulum sem, vel euismod leo dui eu sapien. Maecenas turpis nunc, sollicitudin vel, placerat ac, pulvinar sed, urna. Nunc a dui. Phasellus in magna at odio luctus aliquet.</p>
</div>
</body>
</html>
See How To Clear Floats Without Structural Markup
Since you're using CSS backgrounds in your example, Centauri has shown a method that will give the appearance of a floated image, i.e.,
HTML Code:
#topcontent {
background:transparent url(image.gif) no-repeat 1% 50%;
padding:0 0 0 302px;
}
However, there will be a left margin 302px all the way down to the bottom of the div. Also, with a floated image, height is not an issue, since the image is 150px, and as a contained (and cleared) float, will expand the div to include the full height. Using the CSS background, height will be a factor.
Bookmarks