The HTML and BODY elements are distinct entities, therefore the cascade rules do not apply in this scenario.
Your confusion likely stems from CSS having some specific rules for the HTML and BODY elements:
When the root element of a document is an HTML or XHTML element with 'transparent' background-color and 'none' background-image values, browsers will use the first HTML "BODY" or XHTML "body" child element's computed background properties for painting backgrounds on the canvas, excluding the background of that child element itself.
If you only set styling for one of them, that color will be applied.
For example, setting a red background for the HTML element:
html { background: red; }
In contrast, setting a yellow background for the BODY element results in a yellow background due to these special rules:
body { background: yellow; }
However, if both elements have been styled, these rules do not take effect.
Therefore, the HTML element remains red and the BODY element is yellow, although it may not be visible if there is no content in the body causing its height to be zero.
html { background: red; }
body { background: yellow; }
<p>Hello, world.
<p>With content in the body, the background is now visible as it no longer has zero height.