I know I should use position: relative; so that it follows the inline block behaviour for both the elements so that they don't over lap & are placed inline next to each other because each element is recognized as a block
But I am curious, when position is absolute it no longer recognize that element as a block & allows overlapping, why so?
eg 1:-
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title> Hello </title>
</head>
<body>
<div class="container" style="display:inline-block; background-color:black; height:500px; width:500px; position: relative; left:20px;">
<div class="red" style="display:inline-block; background-color:red; height:100px; width:100px; position: absolute;"></div>
<div class="blue" style="display:inline-block; background-color:blue; height:100px; width:100px; position: absolute; left:20px;"></div>
</div>
</body>
</html>
2:
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title> Hello </title>
</head>
<body>
<div class="container" style="display:inline-block; background-color:black; height:500px; width:500px; position: relative; left:20px;">
<div class="red" style="display:inline-block; background-color:red; height:100px; width:100px;
position: relative;"></div>
<div class="blue" style="display:inline-block; background-color:blue; height:100px; width:100px; position: relative;"></div>
</div>
</body>
</html>