Skip to Main Content
Creating a Website: The Missing Manual, 3rd Edition
book

Creating a Website: The Missing Manual, 3rd Edition

by Matthew MacDonald
May 2011
Beginner content levelBeginner
584 pages
17h 42m
English
O'Reilly Media, Inc.
Content preview from Creating a Website: The Missing Manual, 3rd Edition

Images and Styles

The <img> element supports a few optional attributes you can use to control an image’s alignment and borders. But in the modern world, these attributes are obsolete, and you won’t use them in this book. Instead, you’ll learn the best way to position images—with style sheet rules.

The following sections describe your image-alignment options, and help you practice some of the style sheet smarts you picked up last chapter.

Inline Images in Text

If you don’t take any extra steps, a browser inserts every image right into the flow of HTML text. It lines up the bottom of a graphic with the baseline of the text that surrounds it, as shown in Figure 7-6. (The baseline is the imaginary line on which a line of text sits.)

Usually, you don’t want a picture inside an ordinary line of text (unless it’s a very small emoticon, like the ones you find in instant message programs). You can use paragraphs, line breaks, or tables to do a better job of separating images from your text.

Figure 7-6. Usually, you don’t want a picture inside an ordinary line of text (unless it’s a very small emoticon, like the ones you find in instant message programs). You can use paragraphs, line breaks, or tables to do a better job of separating images from your text.

You can change the vertical alignment of text using the vertical-align property. Specify a value of top, middle, or bottom, depending on whether you want to line the picture up with the top, middle, or bottom of the line of text.

Here’s an example of an inline style that uses the vertical-align property to line a picture up with the top of the line of text.

<img src="happy.gif" alt="Happy Face" style="vertical-align: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Creating a Website: The Missing Manual, 4th Edition

Creating a Website: The Missing Manual, 4th Edition

Matthew MacDonald
Learn to Build a Website

Learn to Build a Website

Cassidy Williams, Camryn Williams

Publisher Resources

ISBN: 9781449306823Supplemental ContentErrata Page