[thelist] Stretching the limits of <img>

Joe Crawford joe at artlung.com
Sun Mar 26 04:54:09 2000


"L. Floyd" wrote:
> 
> I'm trying to do a trick with the <img> tag to produce a horizontal line
> in a multi-column table.  The table width dimensions are relative to the
> users screen width (i.e., not absolute measurements in pixels), so table
> column widths will vary from user to user.  I'm making a fake <hr> by
> using a 1w x 2h image and stretching it using the width attribute of the
> <img> tag.  I want the fake <hr> to stretch across the entire width of a
> column in the table.  Thing is, there's no way to know the absolute
> width of the column, so I can't predict what the width attribute should
> be.  So, I assigned a percentage value to the width attribute (e.g.,
> width="100%") and this seems to work (I've tested it with IE 5, Netscape
> 4.7, and Mozilla M13).  My question is this:  is it "legal" to assign a
> percentage value to the width attribute?  By legal I mean in compliance
> with HTML 4 or just good HTML practice.
> 
> Oh, here's an example of the code:
> <IMG SRC="images/bluegray.gif" WIDTH="100%" HEIGHT="2" BORDER="0">
> 
> - larry
> 
> ps:  The reason I'm asking this at all is because the editor I use is
> highlighting the odd width attribute as an error.  It may be that the
> editor is just not smart enuff to know that a percentage is ok as a
> width value (I won't mention it here... don't want to start a war on
> editors).

It is legal in HTML 4 and 4.01:
http://www.w3.org/TR/html4/struct/objects.html#adef-width-IMG
http://www.w3.org/TR/html4/types.html#type-length

But I'm dimly remembering problems with doing this in Netscape 3? Or
IE3? I forget. :-\

Interestingly though, it is *not* legal in HTML 3.2.
http://www.w3.org/TR/REC-html32.html#img

Considering the problems with mixing percentages and pixels in tables,
my gut would tell me to use something more tried and true (like isaac's
recommendation to use a cell bgcolor) than doing what you suggest.

HTH,
	Joe
--
Joe Crawford...........electronic mail -> mailto:joe@artlung.com
member......international mailing list -> http://evolt.org/
founder..San Diego/CA/USA mailing list -> http://www.websandiego.org/
Web Designer/etc.............about(me) -> http://www.artlung.com/