The code below always show the image irrespective of a relative or absolute position
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title
</title>
<style>
#h1 {
position: relative;
width: 250px;
height: 76px;
left: 0;
top: 0;
background: url("https://dummyimage.com/250x76/000/fff&text=Heading+1") no-repeat;
}
</style>
</head>
<body>
<h1 id="h1">Heading 1
</h1>
</body>
</html>
But this code after adding a span element only shows the image if the position is set to absolute. I can't understand why in the second code the image won't show when the position is relative. And what makes the image appear once the position is set to absolute.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title
</title>
<style>
#h1 span {
position: relative;
width: 250px;
height: 76px;
left: 0;
top: 0;
background: url("https://dummyimage.com/250x76/000/fff&text=Heading+1") no-repeat;
}
</style>
</head>
<body>
<h1 id="h1">Heading 1
<span>
</span>
</h1>
</body>
</html>