I'm currently enrolled in Codecademy's HTML & CSS course and I'm finding the topic of positioning a bit perplexing.
Here is an example of my HTML file:
<!DOCTYPE html>
<html>
<head>
<style>
div {
position: relative;
display: inline-block;
height: 100px;
width: 100px;
border: 2px solid black;
}
div p {
position: relative;
margin-top: 40px;
font-size: 12px;
}
</style>
</head>
<body>
<div><p>Maxime</p></div>
<div><p>Killian</p></div>
<div><p></p></div>
</body>
When I leave the code like this, it doesn't give me the expected result. It only behaves correctly when I add a third name in the third div. Here's a picture for reference: https://i.sstatic.net/ao3hB.jpg
Why are the nested elements (paragraphs) changing the behavior of their parents? Any insight would be greatly appreciated!