Omitting Pixel When Using Inline "width"
A bit of a silly question but important for me to understand. As far as I know when using the inline 'width' attribute in HTML, it is permitted to omit 'px' - - will automatically
Solution 1:
This is never stated outright in the HTML 4 or older specs, but all HTML DTDs that support width
and related presentational attributes don't impose any restrictions on %Pixels
values — they simply state in prose that they should be integers, but are defined in the DTD as CDATA:
<!ENTITY % Length"CDATA" -- nnforpixelsornn% forpercentagelength --><!ENTITY % Pixels"CDATA" -- integerrepresentinglengthinpixels -->
So, technically, it's not wrong, in fact you could put anything you want and
- it'd still validate against the HTML 4 DOCTYPE; and
- browsers would simply parse the attribute value as either an integer or a percentage.
All of the following are functionally equivalent, producing tables that are 200 CSS pixels wide (because none of the values can be parsed as a percentage):
<tableborder="1"width="200"><tr><td><code>width="200"</code></table><tableborder="1"width="200px"><tr><td><code>width="200px"</code></table><tableborder="1"width="200abcd"><tr><td><code>width="200abcd"</code></table><tableborder="1"width="200x10px"><tr><td><code>width="200x10px"</code></table>
Post a Comment for "Omitting Pixel When Using Inline "width""