how to set width of image ... and a pointer to plug-webdev

Bill Lindley wlindley at wlindley.com
Wed Mar 7 02:00:48 MST 2007


Josef Lowder wrote:
> .
> What is the syntax to set the width of images that are to 
> be called by a simple text list of images? 
>
> <a href="http://www.name.com/pix1.jpg" width=800>photo #1</a><br>
>   
If your intention is that clicking the link will display the picture, 
resized to 800 wide... well, you can't do it that way.

As has been noted, you can link to an HTML file that contains the 
picture with an <img src="..." width="800"> (and it's more 
"standards-compliant" but not required to put all arguments like 800 in 
quotes)

BUT...!

If the original picture was 3000 pixels wide and a 5 megabyte .jpg, the 
whole 5 megabytes will be squeezed through the viewer's bandwidth, and 
then his browser will do a horrible job of resizing it to 800 pixels 
across. "Horrible job" because the image will come out jagged and 
blocky, because browsers generally do straight "sampling" (e.g., just 
picking every third pixel) rather than "averaging" (looking at three or 
four pixels and computing the average color). The result will be a slow, 
unpleasing web page.

SO -- the real answer is,

** Resize your photo to 800 pixels before you upload it! **

Using the width= attribute to force browser resizing is almost always a 
bad idea and almost never does what you really wanted.

\\/
http://www.wlindley.com

p.s., For future questions, the webdev list is at:

http://lists.plug.phoenix.az.us/mailman/listinfo/plug-webdev

...I had completely forgotten about it. Perhaps there should be a 
monthly reminder here, of the various PLUG email lists. Aha, the list of 
lists is at:

http://plug.phoenix.az.us/index.php?option=com_content&task=view&id=14&Itemid=30



More information about the PLUG-discuss mailing list