Chapter 14. Aligning Images

Image

“Sometimes you want to give up the guitar, you’ll hate the guitar. But, if you stick with it, you’re gonna be rewarded.”

—Jimi Hendrix

Adding an image to a web page is fairly straightforward. While the img element has its own alignment attribute, it’s now better practice to control image alignment through CSS.

You can use CSS to control where the image appears in relation to other elements using relative positioning, floats, and margins. Alternatively, you can control an image’s position with respect to the browser window with absolute positioning and values from the browser edge (such as left and top).

In this chapter ...

Get Designing Web & Mobile Graphics: Fundamental Concepts for Web and Interactive Projects 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.