#container img {max-width: 100%; max-height: 100%;}Is there a better way to do this?
Image Size Definition
-
- Posts: 66
- Joined: Thu Jan 12, 2012 3:54 pm
- Contact:
Image Size Definition
Are there any disadvantages of not defining the width and height of an image withing an <img> tag apart from making the browser waste cycles working out how big the image should be? I am using CSS to set a maximum width and height, within a custom <div> tag. I am doing this in order to make the site design responsive, i.e. the page displays correctly for the size of screen you're viewing it on and yet only having the one version of the image, The code I currently have is
Re: Image Size Definition
I always thought it was just a good practice, I dont think there's any real advantage to declaring the dimensions.
JoshRoche
JoshRoche
Re: Image Size Definition
That way is fine, like you say the reason people say you should include the dimensions is because if you don't the browser has to work it out.
I think there is some rendering fail with old versions of IE too but that is not really something to worry about any more.
I think there is some rendering fail with old versions of IE too but that is not really something to worry about any more.