02-12-2004, 10:31 AM
i have gotten in the habit of not doing so, with rare exception. i fail to see the need. i have never had any problems with <img /> boxes taking on wacky proportions as a result of this practice. and especially if you need to adjust the slicing of a larger graphic, or simply the dimensions of a whole one, leaving the markup dynamic just makes the most sense to me. but i see width and height attributes all the time, so are there some advatages to using them that i'm not familiar with?
02-12-2004, 11:00 AM
Both those attributes are depricated no? I never use them, I never set a width for any image.
02-12-2004, 11:30 AM
Back in the good ol' days, explicitly setting width and height on images was meant to help the browser reserve a space for it before the actual image was loaded, thus preventing the need for re-rendering the page every time an image finished loading.
Since these attributes are deprecated, width and height would have to be set through a style sheet, or - and this is probably one of the rare appropriate applications of it - through an inline style on the image itself.
Seperation of content and presentation gets fuzzy here, since the width and height of an image - when used as content - arguably are aspects of content, and not of presentation.
02-12-2004, 11:31 AM
hmm. i can see your point i suppose, but it always seemed like this supposed "re-rendering" you speak of was no different than how the browser shifts content when the window itself is resized. and this doesn't involve any actual re-rendering (as far as downloading).
02-12-2004, 11:51 AM
The difference there is that on resizing a page already loaded, the browser has all the page elements in cache and "knows" how much room the various elements require; it only needs to shift them around a bit.
On loading a new page, laden with images, the browser first renders the page with all the readily available elements (text, etc.), then for each image finishing loading, it has to rearrange the page to acommodate that image, which may need more space then initially acounted for.
Try refreshing the main page or a forum main page on this site to see the effect of image placeholders being replaced by actual images.
Discussed previously (http://annevankesteren.nl/archives/2004/01/images-height-and-width-attributes). I hold with my argument.
The attributes ARE NOT deprecated, by the way. Look at the XHTML Strict DTD (http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict), and do a text search for 'height' (Ctrl+F in most browsers). Should be the second item that comes up. Here's a quote if you can't be bothered:
<!ELEMENT img EMPTY>
src %URI; #REQUIRED
alt %Text; #REQUIRED
longdesc %URI; #IMPLIED
height %Length; #IMPLIED
width %Length; #IMPLIED
usemap %URI; #IMPLIED
ismap (ismap) #IMPLIED