Image Size Definition

Anything questions related to styling should go in here.
Post Reply
wrichards8
Posts: 66
Joined: Thu Jan 12, 2012 3:54 pm
Contact:

Image Size Definition

Post by wrichards8 »

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[syntax=css]#container img {max-width: 100%; max-height: 100%;}[/syntax]Is there a better way to do this?
User avatar
JoshRoche
Posts: 2
Joined: Tue May 14, 2013 6:16 pm
Contact:

Re: Image Size Definition

Post by JoshRoche »

I always thought it was just a good practice, I dont think there's any real advantage to declaring the dimensions.

JoshRoche
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Image Size Definition

Post by jacek »

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.
Image
Post Reply