kohoutek, can you explain how you know the “default unit” for WIDTH is pixels?
Let’s say for example you have as follows: <img src=“…” alt=“…” /> the IMG is an empty ‘replaced element’ thus would not have a “default unit” for a “width”.
If anything it would be a percentage (%) width if I understand it correctly and not actually pixel units.
I assume you meant if the IMG had a WIDTH attribute omitted and no CSS was involved that you believe it would be replaced by “pixel units”, which I cannot see is the case.
Or do you actually mean the actual image SRC file let’s say ‘sample.png’ would “default override” and force the issue.
Otherwise I cannot see how it has a default unit in the absence of either CSS or an explicit ‘width’ value, i.e. =“100” or “100%” .
If I ‘misunderstood/misread’ your answer; then that’s fine.
No, that is not valid CSS. You have to specify a unit for all non-zero values.
For values that are zero, it’s optional to specify a unit. I personally recommend omitting them.
In this case it is an error to add a ‘px’ unit. Length values in HTML attributes are automatically in pixels, unless you add a ‘%’ character at the end.
Like I said it doesn’t say pixels but %Length; and as it is replaced it cannot have a known default unit.
What I originally meant it can be either; ‘pixel’ or ‘percentage’ just in case I wasn’t clear. Most likely I just misread her answer to mean; “only” pixel would be ‘default’.
I’m not sure anyone actually said but in a strict doctype values without a unit will be treated as zero so the above will be rendered as padding:0 0 0 0;
Are you sure that they actually get treated as zero or is it just that the default unit is attometres and so the distances are sub-microscopic but still there and just get rounded to zero. I guess if you specified sizes like 1000000000000000000000000 we could find out since that many attometres would actually round up to be a pixel:):)
Thanks, I suspected as such - I misread the answer - I have a damn head-cold at the moment; and that combined with word-blindness means my reading ability diminishes considerably.
Ah, I see they actually changed the values slightly from 3.2 to 4.01:
That explains why you said that; you were referring to an earlier version where it got treated differently - previously pixels only - interesting nonetheless.
I really don’t see there being much to contend about, it’s almost like saying “how long is a piece of string”, providing unit numbers without the implied unit value is pretty crazy. Especially as the unit values have a very big difference between how the design would be affected as a result. Why play guessing games with the rendering engines, there’s enough “loose” interpretations of the spec’s without designers confusing the browsers to boot with generic number values.