concept
percentage-resolution — CSS reference
A percentage is relative to a reference defined by the property, not necessarily the element itself or the viewport. For ordinary horizontal block layout, width and percentage padding resolve against the containing block’s inline width. Percentage heights may need a definite reference size.
Formal Syntax & Structure
css syntaxcss
width: 50%; padding-inline: 10%;Working Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS reference lab</title><style>#parent {width:200px;height:100px} #a {width:50%;height:50%;padding-inline:10%}</style><body><div id="parent"><div id="a">Sample</div><div id="b">Comparison</div></div></body></html>