Line breaks within

Giganews Newsgroups
Subject: Line breaks within <div>
Posted by:  lars…@hotmail.com (Lars)
Date: 3 Dec 2003

Hello all,

Having googled around without any luck, I resort to posting my own
question: Is there any way I can make a <div> adjust to the width of a
contained image and line break any long text instead of expanding the
<div>?

The background of the problem is that I use a nested <div> to contain
an image and its caption. I float the entire <div> to the right in its
containing <div>.

<div #id="img">

    <img src="image.jpg" border="0" alt="Some image" />

    <p>A long caption that extends the horizontal width of the
image</p>

</div>

I use the following CSS:

#pagebody #img {
    float: right;
    margin: 15px;
    }

#pagebody #img p{
    font-family: tahoma, arial, helvetica, sans-serif;
    font-size:  x-small;
}

What can I do to make the text behave according to plan? Thanks for
you help!

/Lars

Replies