In block-level elements, the height of the content-box is defined by the distance from the top of the content to one of the following (depending on the presence of an inline formatting context (IFC) or block formatting context (BFC)):
If the element has a height set explicitly, the height of the content-box is simply that value.
For inline elements, the height of the content-box is not explicitly defined and depends on the font size and other font properties. The vertical margin, border, and padding of an inline element start at the top and bottom of the content-box, but do not affect the height of the line box.
In the provided HTML snippet, the height of the content-boxes are as follows:
):
The height is equal to the line-height (2em) because it establishes an IFC with one line.The above is the detailed content of How is the Height of Content-Boxes Determined for Block and Inline Elements?. For more information, please follow other related articles on the PHP Chinese website!