22.04.2013 Views

HTML, XHTML & CSS

HTML, XHTML & CSS

HTML, XHTML & CSS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

12<br />

Part II: Formatting Web Pages with (X)<strong>HTML</strong><br />

This means you can use alternative text to describe the image to those who<br />

can’t see it and/or title text to provide useful (or amusing) information about<br />

the same image.<br />

The W3C’s Web Accessibility Initiative (WAI) includes helpful tips for creating<br />

useful and usable alternatives to visual content at www.w3.org/TR/<br />

WCAG10-TECHS/#gl-provide-equivalents.<br />

Specifying image size<br />

You can use the height and width attributes with the element to<br />

let the browser know just how tall and wide an image is (in pixels; px):<br />

Brass<br />

Most browsers download the <strong>HTML</strong> and text associated with a page before<br />

they download the page graphics. Instead of making users wait for the whole<br />

page to download, browsers typically display the text first and then fill in<br />

graphics as they become available. If you tell the browser how big a graphic<br />

is, the browser can reserve a spot for it in the page display. This speeds the<br />

process of adding graphics to the Web page.<br />

You can check the width and height of an image in pixels in any image editing<br />

program, or in the image viewers built into Windows and the Mac OS. (You<br />

might be able simply to view the properties of the image in either Windows<br />

or the Mac OS to see its height and width.)<br />

Another good use of the height and width attributes is to create colored<br />

lines on a page by using just a small colored square. For example, this<br />

markup adds a 10-x-10-px blue box to a Web page:<br />

<br />

Use the element height and width attributes to set image height<br />

and width. Thus we use these values to create a 10-x-10-px blue box in a<br />

browser window (shown at the top of Figure 7-5) even though the original<br />

image is 600 x 600 px. In general, it’s safe to reduce image dimensions using<br />

these attributes although you’ll always want to check the results carefully<br />

during testing. With any kind of aspect sensitive image, you want to maintain<br />

its aspect ratio by dividing the original dimensions by some common value.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!