Fallback for CSS Attributes Without Unit
In CSS, when a unit (e.g., px, em, pt, %) is missing from an attribute, browsers handle the situation differently.
Quirks Mode Behavior
In quirks mode, some browsers may fall back to a preferred unit, typically px. This behavior is based on the legacy of unitless HTML attributes like width and height.
Standards Mode Behavior
In standards mode, as per CSS2.1 specifications, all non-zero length values require units. UAs are expected to ignore length values without units.
Browser Inconsistencies
Despite the standardized behavior in standards mode, browsers exhibit inconsistencies in quirks mode:
W3C Requirements
The W3C does not dictate the behavior for unitless CSS attributes in quirks mode. The specifications only mandate that UAs ignore unitless length values in standards mode.
Specific Questions:
The above is the detailed content of How Do Browsers Handle Missing Units in CSS Attributes?. For more information, please follow other related articles on the PHP Chinese website!