I had a good understanding of how inline elements function. But I came across a helpful explanation here: CSS display: inline vs inline-block.
Regarding inline elements:
- respect left & right margins and padding, but not top & bottom
Inline elements only acknowledge right and left padding, disregarding any padding specified for top and bottom. However, my recent tests revealed an unusual behavior. When applying padding to an inline element, it seems to apply it to the left, right, and bottom but not the top.
Can anyone provide an explanation for this particular behavior?
<html>
<head>
<style>
* {
box-sizing: border-box;
padding:0;
margin:0;
}
.parent{
display:inline;
background-color: red;
padding: 10rem;
color:white;
}
</style>
</head>
<body>
<div class="parent">Whatever</div>
</body>
</html>