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.
A calc() expression in the left property contains a word starting with "n", such as none or NaN, where a number or a length should be.
Inside calc() and the other math functions (min(), max(), clamp()), each operand must be a number, a length, a percentage, or a var() reference. When the validator finds a word instead, it tries to read it as a number and reports the word's first letter. calc(50% - none) reports "Character n", and calc(50% - NaNpx) reports "Character N". Words starting with other letters give the same message with that letter, such as "Character a" for auto.
NaN usually comes from a script or template that computes the position. If the calculation divides by zero or reads a value that isn't a number, calc(50% - {{ offset }}px) comes out as calc(50% - NaNpx). Keywords such as none or auto are valid on their own (left: auto) but not as operands of calc(). Browsers ignore the whole declaration, so the element gets the left value it would have without it.
To fix it, put a length in place of the word, or make sure the template variable always holds a number. If the value comes from a custom property, var() is fine inside calc(), and a fallback covers the case where the property isn't set: calc(50% - var(--offset, 0px)).
Outside calc(), other mistakes in left give different messages: left: 10 says only 0 can be written without a unit, and left: NaNpx says the value is not a left value.
Invalid example
<div class="tooltip" style="position: absolute; left: calc(50% - NaNpx);">Copied</div>
Valid example
<div class="tooltip" style="position: absolute; left: calc(50% - 120px);">Copied</div>
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, or20ppxinstead of10px. - Unsupported keywords: Using values like
none,center, ormiddle, which are not valid for theleftproperty. - Missing units on non-zero numbers: Writing
left: 10instead ofleft: 10px. Zero is the only number that doesn't require a unit. - Typos in keyword values: Writing
auтоorautooinstead ofauto. - CSS custom properties in inline styles: Using
var(--offset)in astyleattribute 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 as10px,2em,3rem,1vw.<percentage>: A percentage relative to the containing block's width, such as50%.auto: Lets the browser determine the position (this is the default).- Global keywords:
inherit,initial,unset, andrevert.
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.
Validate at scale.
Ship accessible websites, faster.
Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.
1K Weekly
1,000 monthly checks. Cancel anytime.
Get 1K Weekly →Join teams across 40+ countries