I want to display a picture in a table cell. If I set the height & width attributes of the tag to 100%n how will the image be displayed, I.e.; at 100% of the original image size, or will it be resized to 100% of the specified cell size?

2 answers

1
point

Edit:

I see that I didn't quite get the question this morning. I don't really get why you would want to set an image's width/height in percentages. Can't you just set it to it's own width/height in pixels? This will cause the image to retain it's original quality.

Read: Always Set the Image Width and Height to the Real Image Size

To answer it though: I think it will scale to the width and height of it's parent element.


When placing an image in a table cell the image will retain it's own width and height, it won't scale with the table cell (unless you tell it to, with css for example).

The image tag in html can be set to a specific width and height (in pixels) of itself like so:

<img src="path/to/image" width="150" height="300" alt="Alternate image text"/>

You can also set the properties of an image with css:

img {
 width:150px;
 height:300px;
}
Answered over 7 years ago by Jesse Vlasveld
0
points

According to the spec lengths expressed as percentages are based on the horizontal or vertical space currently available, not on the natural size of the image.

so to answer your question, the image should scale to the size of the table cell.

should being the operative word - different browsers may handle it differently.

YMMV as they say!

Answered over 7 years ago by Tony Crockford