2013-05-01 8:02, tlvp wrote:
> For img, TABLE, and TD tags, I'm familiar with use of WIDTH attribute, and
> for img and TR tags, with HEIGHT attribute as well, each with values of the
> form: an integer (representing that many pixels); or a percentage (to
> represent the relevant portion of the available space, where applicable).
For attributes that specify dimensions, HTML has always (i.e., ever
since such attributes came to life) had their values with pixel as the
implied unit, and from HTML 4.0 onwards (and in browser practice before
that), percentage as the other option.
> Should it be possible to use lengths in other units as well, such as the
> em, the centimeter (cm), the inch (in), the millimeter (mm), etc? If the
> answer depends on the HTML level, please indicate how
No, not in HTML, only in CSS.
If you try to use, say, width="42mm" in HTML, browsers will interpret it
as width="42". That's because they parse the value using a routine that
scans an integer and stops as soon as it gets a character that cannot be
part of an integer. This is why width="42px" works, so to say, which may
have made people try other units, too.
As far as I can remember, there haven't even been any proposals or
browser-specific inventions that would have differed from this, except
the point-size attribute that Netscape invented for <font> and that died
with Netscape.
Oh, wait... one might say that the size attribute in <input> is a
dimension attribute of a kind, and it differs from the pattern. Its
value, specifying the suggested visible width of the input box, is
interpreted as a number of characters. This has never been defined
reasonably, since the widths of characters vary (except for monospace
fonts), usually a lot, and browsers have implemented the attribute in
very varying ways.
This isn't a serious restriction, since you can use CSS instead - even
directly embedded into an HTML tag, e.g. <td style="width: 3em"> or, to
use a nice though still poorly implemented CSS3 unit, <td style="width:
6ch">. (The ch unit intuitively means "average character width", but it
has been defined rigorously to denote the width of the digit "0".)
--
Yucca,
http://www.cs.tut.fi/~jkorpela/