Re: "px" in the width/height attribute for IMG

On Mon, 21 Apr 2003, David Håsäther wrote:

> I have seen some people including px when they specify width/height for
> an image like <img src="example.png" alt="" width="100px"
> height="100px">

It's a relatively common error. It's certainly an error, since it violates
the prose descriptions in the specification. Usually the error is caused
by the fact that people have difficulties in distinguishing between HTML
and CSS syntax. On the other hand, most (if not all) browsers simply
ignore the px part there.

> and the validator does not catch this fault.

That's correct, since the error is not a reportable markup error. It does
not violate the formal syntax specified by the DTD. Similarly,
width="whatever I put here" is valid, in the technical sense of
validation, but surely not correct. Since the width attribute can take
percentage values too (e.g., width="100%"), it wouldn't even be possible
to write a DTD that allows what the HTML specification allows and
disallows everything else. That is, the permitted format of values cannot
be described in SGML (or in XML).

-- 
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/

Received on Monday, 21 April 2003 10:35:05 UTC