Value resolution stages
Definition and purpose
A CSS property passes through distinct value stages. Declared values are candidates; the cascaded value is the winner; the specified value includes defaulting; the computed value resolves dependencies as required by the property; the used value incorporates layout; the actual value reflects device constraints.
Percentage used width
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } #parent { width: 240px; } #a { width: 50%; } </style> </head> <body> <div id="parent"> <div id="a">Panel</div> <div id="b">Other</div> </div> </body></html>CSSOM reports 120px; layout resolved the percentage.
Syntax and mental model
For width: 50% in a normal block with a 240px containing block, the computed percentage remains 50% and the used width is 120px. CSSOM getComputedStyle() returns a resolved value, which for a rendered width is often the used pixel length. getBoundingClientRect() reports geometry including transforms and borders, not the formal computed width.
Rendered versus resolved
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } #a { width: 100px; padding: 10px; transform: scaleX(2); } </style> </head> <body> <div id="parent"> <div id="a">Panel</div> <div id="b">Other</div> </div> </body></html>The content width remains 100px while the transformed border box is 240px.
Common mistakes
Do not infer that a percentage was replaced during computation merely because DevTools or CSSOM displays pixels. Consult the property definition for its computed value.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Native nesting. Next lesson: Animation and transition precedence.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Value resolution stages — knowledge check
Five questions on value resolution stages.
What follows cascade selection and defaulting?
Which stage accounts for layout?
For ordinary block width:50%, what can the computed value remain?
Does getComputedStyle always expose the formal computed value?
What can getBoundingClientRect include?