O'Reilly logo

Microsoft® HTML5 Step by Step by Faithe Wempen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Controlling Image Size and Padding

Image size is expressed in pixels. If you want, you can specify only the width; the height will be resized proportionally, or vice versa. But you also have the option to specify both the width and the height. For example, suppose the following is your original image, which is 150 pixels high:

image with no caption

You could add a height=“75” attribute to the <img> tag, without specifying a width, like this:

<img src="tree.gif" style="float: left" height="75">

When you view the page, the image shrinks proportionally, like this:

image with no caption

However, if ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required