Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Or in the HTML.


Preferably in the HTML.

Unless width="" and height="" have been deprecated on <img> overnight.


Different use cases IMO. If it's a single image of variable size, use width and height. If there are a bunch of images, all the same size (thumbnails for instance), use CSS.


If you specify width and height explicitly, certain browsers will have issues resizing them (if you set max-width: 100%, Chrome will squish a larger image horizontally but leave the height as it was, IE will scale it proportionally).


I think that's because Chrome treats width= and height= as if they were CSS. (have a look at the inspector on an element with width and height specified in the HTML)


That makes sense (thank you, don't know why I didn't realize that myself), but if I override that with css height: auto; , the browser no longer reserves space for the image while loading it... quite unfortunate.


Maybe you should submit a WebKit (or possibly Chromium if this is Chrome-specific) bug for this.


Why do you say Preferably in the HTML? Just curious. I vaguely recall there was a reason.


Because it has been the standard way for a long time.

And because it allows browsers to make room for the image and avoid reflowing.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: