HTML Guides for left
Learn how to identify and fix common HTML validation errors flagged by the W3C Validator — so your pages are standards-compliant and render correctly across every browser. Also check our Accessibility Guides.
The W3C validator parses inline CSS values character by character. When it encounters a numeric value for the left property, it expects the characters that follow to be part of a valid number (digits, a decimal point, or e for scientific notation) or a recognized CSS unit. If it instead finds an unexpected letter like n, it raises this error. This can happen in several ways:
- Missing units: Writing left: 10; instead of left: 10px;. The CSS specification requires a unit for all non-zero length values. While some browsers may interpret unitless numbers in quirks mode, this is invalid CSS and produces unpredictable results across browsers.
- Typos in units: Writing something like left: 10n; or left: 10xp; where the intended unit was px but a typo introduced invalid characters.
- Template or scripting artifacts: Dynamically generated values like left: {{offset}}px; that weren’t properly resolved, leaving non-numeric characters in the output.
- Using calc() incorrectly: Writing left: 10 + 5px; instead of left: calc(10px + 5px);.
The left property accepts the following value types:
- Lengths: A number followed by a unit such as px, em, rem, vw, vh, ch, etc. (e.g., left: 10px;)
- Percentages: A number followed by % (e.g., left: 50%;)
- Keywords: auto, inherit, initial, unset, or revert
- Functions: calc(), min(), max(), clamp(), etc.
- Zero: The value 0 is the only number that does not require a unit.
Invalid CSS not only triggers validation errors but can cause layout issues. Browsers may ignore the entire declaration, falling back to the default value, which can break your intended positioning. Ensuring valid CSS improves cross-browser consistency and maintainability.
Examples
Missing unit (triggers the error)
<div style="position: absolute; left: 10;">
Positioned element
</div>
The validator reads 10 and then encounters the ; (or in other cases a stray letter like n), which is not a valid part of a CSS length value.
Typo in unit (triggers the error)
<div style="position: absolute; left: 10xn;">
Positioned element
</div>
Fixed with a valid length unit
<div style="position: absolute; left: 10px;">
Positioned element
</div>
Fixed with a percentage
<div style="position: absolute; left: 50%;">
Positioned element
</div>
Fixed with the auto keyword
<div style="position: absolute; left: auto;">
Positioned element
</div>
Fixed with calc()
<div style="position: absolute; left: calc(50% - 20px);">
Positioned element
</div>
Zero without a unit (valid)
<div style="position: absolute; left: 0;">
Positioned element
</div>
Always double-check that every non-zero numeric value for left (and other length-based properties like top, right, bottom, width, margin, etc.) includes a valid CSS unit. If you’re generating styles dynamically, verify that template variables resolve to proper values before rendering.
The left property specifies the horizontal offset of a positioned element — one that has its position set to relative, absolute, fixed, or sticky. The W3C validator checks CSS within style attributes and <style> elements, and it will flag any value it cannot recognize as a valid left value.
Common causes of this error include:
- Misspelled or non-existent units: Writing 10 px (with a space), 10pixels, or 20ppx instead of 10px.
- Unsupported keywords: Using values like none, center, or middle, which are not valid for the left property.
- Missing units on non-zero numbers: Writing left: 10 instead of left: 10px. Zero is the only number that doesn’t require a unit.
- Typos in keyword values: Writing auто or autoo instead of auto.
- CSS custom properties in inline styles: Using var(--offset) in a style attribute may trigger validation warnings depending on the validator’s CSS level.
The valid values for the left property are:
- <length>: A numeric value with a unit, such as 10px, 2em, 3rem, 1vw.
- <percentage>: A percentage relative to the containing block’s width, such as 50%.
- auto: Lets the browser determine the position (this is the default).
- Global keywords: inherit, initial, unset, and revert.
Using an invalid value means the browser will ignore the declaration entirely, which can break your layout. Fixing these values ensures consistent rendering across browsers and compliance with CSS standards.
Examples
Invalid: Using an unsupported keyword
The keyword none is not a valid value for the left property.
<div style="position: absolute; left: none;">Positioned element</div>
Invalid: Missing unit on a non-zero number
A bare number (other than 0) is not valid without a CSS unit.
<div style="position: relative; left: 20;">Shifted element</div>
Invalid: Misspelled unit
The unit xp does not exist in CSS.
<div style="position: absolute; left: 15xp;">Positioned element</div>
Valid: Using a length value
<div style="position: absolute; left: 20px;">20 pixels from the left</div>
Valid: Using a percentage
<div style="position: absolute; left: 50%;">Offset by 50% of containing block</div>
Valid: Using the auto keyword
<div style="position: absolute; left: auto;">Browser-determined position</div>
Valid: Using zero without a unit
Zero does not require a unit in CSS.
<div style="position: absolute; left: 0;">Flush with the left edge</div>
Valid: Using inherit
<div style="position: relative; left: inherit;">Inherits left value from parent</div>
To fix this error, identify the invalid value the validator is reporting and replace it with one of the accepted value types listed above. If you intended to reset the position, use auto or 0. If you meant to remove a previously set left value, use initial or unset rather than an unsupported keyword like none.
Ready to validate your sites?
Start your free trial today.