To uncover the solution to your query, it is imperative that you delve into the specifications:
According to https://www.w3.org/TR/CSS22/visudet.html#x3, percentage widths are defined as follows:
<percentage>
Specifies a percentage width. The percentage is
calculated with respect to the width of the generated box's containing
block.
Regarding containing blocks:
The link at https://www.w3.org/TR/CSS22/visudet.html#containing-block-details explains:
The position and size of an element's box(es) are sometimes calculated
relative to a certain rectangle, called the containing block of the
element. The containing block of an element is defined as follows:
The containing block in which the root element lives is a rectangle
called the initial containing block. For continuous media, it has the
dimensions of the viewport and is anchored at the canvas origin;
(...)
The root element refers to <html> (https://www.w3.org/TR/html-markup/html.html).
The screen falls under the category of continuous media.
The association between viewport and canvas is straightforward:
https://www.w3.org/TR/CSS22/visuren.html#viewport
https://www.w3.org/TR/CSS22/intro.html#canvas
User agents for continuous media generally provide users a viewport (a window or other viewing area on the screen) through which users consult a document. User agents may alter the document's layout when the viewport is resized (refer to the initial containing block).
If the viewport is smaller than the canvas area where the document is displayed, the user agent should offer a scrolling mechanism.
In essence, the canvas size accounts for content even if it extends beyond the browser window.
The viewport encompasses the browser window without menus, scroll bars, or status bars.
Hence, if <body>
has a 100% width, it would mirror the width of the <html>
element, equivalent to the viewport's width.
You can easily ascertain the viewport width by examining the CSS properties of the <html>
element using Chrome's inspection tool.