Controlling Image Size and Padding

Image size is expressed in pixels. You can specify only the width, and the height will be resized proportionally, or vice versa. You can also specify both the width and the height. For example: suppose this is your original image, which is 200 pixels high.

Controlling Image Size and Padding

You could add a height=100 argument to the <img> tag, without specifying a width, like this:

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

The image shrinks proportionally, like this.

Controlling Image Size and Padding

However, if you specify both height and width of 100, like this:

<img src="tree.gif" ...

Get HTML and XHTML Step by Step 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.