Tutorial 2 - Floating an image and caption

Step 4 - Apply margin to the div

Margins can be added to push the content away from the left and bottom sides of the div containing the image and caption.

Netscape 4 badly misinterprets margins. To hide margins from this browser, but allow them to be applied by standards compliant browsers, place the margin rules in a separate style sheet and use "@import" to link the style sheet to your html page.

We are using a shorthand rule here: "margin: 0 0 10px 10px;". Keep in mind that shorthand values are applied in a clockwise order; top, right, bottom, left.

Go to Step 5 →


Caption here

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.


CSS CODE
.floatright
{
float: right;
width: 100px;
margin: 0 0 10px 10px;
}

HTML CODE
<div class="floatright">
<img src="images/image.gif" alt="" width="100" height="100"><br>
Caption here
</div>
<p>
Lorem ipsum dolor sit amet, consectetuer...
</p>
Other Max Design articles and presentations
Associated with webstandardsgroup.org