Positioning Elements Absolutely

The elements in your Web page generally flow in the order in which they appear. That is, if the img tag comes before the p, the image appears before the paragraph. You can take elements out of the normal flow—and position them absolutely—by specifying their precise position with respect to the nearest positioned ancestor or to the body.

Figure 11.30. Our photo is still sitting above the text in the photo_text div. We want to shift it down into the space that we’ve set aside in the left margin.

To position elements absolutely:

1.
Type position: absolute; (don’t forget the semicolon; the space is optional).

Get HTML, XHTML, & CSS, Sixth Edition: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.