Add image dimensions to html img tag - #56
Conversation
Img tags should have height and width attributes if possible at all. If not specified, the tag will add them.
|
I disagree; this should be done in CSS (inline if you must). Adding them in the HTML just makes things look cluttered later. EDIT: And if you need them in the HTML, you can do it yourself easily enough. |
|
I agree with this. Not including height/width can cause weird rendering jumps and doing it yourself means you need to know what the dimensions are every time; if they are automatically calculated, why not use that? @datenimperator can you update the specs or do you need any assistance with that? |
|
@SamWhited You're right, it's kind of clumsy to have (possibly conflicting) width/height attributes in css and html. However, I see that at least once width/height should be set. <img src="" width="20" height="45" > vs.
<img src="" style="width:20px; height:45px" >Looking at it, the html attribute is shorter and more readable. @saturnflyer I need to be able to run the specs. Then I could add proper tests, too. |
|
This sums up my opinion: http://code.google.com/speed/page-speed/docs/rendering.html#SpecifyImageDimensions |
|
Actually, that's a good point. As much as I hate seeing this sort of thing in the HTML, it does prevent some (sometimes serious) rendering issues, and is a lot faster than loading and parsing an external stylesheet. |
|
I'm in favour but only as an option rather than in-forced, not specifying allows the browser to redraw the image in responsive containers. |
Img tags should have height and width attributes if possible at all. If not specified, the tag will add them.