If you're interested in a javascript soluton, this demo set the width of the div containing the image and text to whatever the physical width of the image is in pixels.
The text then wraps to stay within the container div.
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>
<title></title>
<style type="text/css">
#container {
border: 1px solid red
}
</style>
<script type="text/javascript">
var picO = new Image();
picO.src = 'pic1.jpg';
window.onload=function() {
document.getElementById("myPic").src = picO.src;
//set the container div width to the pic width
document.getElementById("container").style.width = picO.width+'px';
}
</script>
</head>
<body>
<div id="container">
<img id="myPic" src="" alt="">
<p>
Lorem ipsum dolor sit amet, tellus et. Molestie auctor nisl faucibus ut, lorem tortor mattis, fusce nullam enim fringilla vel.
Mauris vitae gravida dolor praesent. Id in nascetur aut odio, nam et. Pede libero bibendum sit felis pretium sodales, fusce
pharetra vestibulum bibendum morbi ultricies nullam, est nulla, id amet mollis. Nec consectetuer urna dapibus luctus ut,
ipsum nascetur consequat dapibus dui ac molestie, est nascetur id nec nunc. Mi etiam mauris facilisi sed, nec ut id,
aliquam non, taciti donec ut.
</p>
</div>
</body>
</html>
Bookmarks