I am trying to add a caption to an image. The way I have done it is by enclosing the image and caption text within a div tag. The problem is that the outer div will not wrap round the image unless I set a specific width, obviously. I don't want to set a width as I want to be able to use it on other images in the website that may have a different width. Is there a simple way of achieving what I want to do without the use of tables or java script. Below is the HTML and CSS that I'm using.
HTML
CSSHTML Code:<div class="image"> <img src="Imageurl" /> <div class="caption">Description of image</div> </div>
Code:.image{ margin:5px; height:auto; } .caption { font-style:italic; font-size:11px; }



Reply With Quote
Bookmarks