property
width — CSS reference
Sets the preferred physical horizontal size. Initial auto; not inherited. Percentages depend on the corresponding containing-block dimension and layout rules; an indefinite block dimension may prevent percentage height resolution. Min/max constraints can override the preferred size.
Formal Syntax & Structure
css syntaxcss
auto | <length-percentage [0,∞]> | min-content | max-content | fit-content(<length-percentage [0,∞]>) (core values)Working Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS box geometry lab</title><style>body {margin:0} .sample {background:#dcebe9;color:#182e32}#parent{width:240px;height:160px} #a{width:50%;height:20px}</style><body><div id="parent"><div id="a" class="sample">Box</div></div></body></html>