Forum Moderators: not2easy
<html><head>
<style type="text/css">
div.answer { width:40%; }
div.question { border-style: solid; }
img.trafficlight { float: right; border-style:solid; display: block; }
</style>
</head><body>
<div class="question">
<img class="trafficlight" src="trafficlightredlit.png">
bar
<div class="answer" >foo</div>
</div></body></html>
The image sticks out of the bottom of the <div class="question"> box.
I have tried using "display: block" as shown, but it did not work.
What can I do to stop the image going outside the box?
Simplest first is play with overflow on the parent div as suggested - but if this is in a complex layout, you can contain the floated image by floating the parent div because floated elements will always clear to all their children.
Recent nightmare with containing elements [webmasterworld.com]. :-)