I need a span to be displayed as a marker BENEATH important texts on my page.
It should have been positioned at the bottom of the p element – but it does not.
Can someone tell me what’s wrong in the code?
.marker {
position: absolute;
bottom: 0px;
background-color: red;
height: 3.9px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="a.css">
</head>
<body>
<div>
<p>
This is
<span>IMPORTANT INFORMATION THAT NEEDS TO BE EMPHASIZED
<span class="marker"></span>
</span>
</p>
</div>
</body>
</html>
>Solution :
Quote in comments: "What is it that you actually try to do? Do you want to mark that by underlining it?
Respond of OP: "Yes, exactly"
XY problem here. Instead of using a pseudo-element and positioning it, Simply add the underline as border-bottom to element itself:
.marker {
border-bottom: 3.9px solid red;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="a.css">
</head>
<body>
<div>
<p>
This is
<span class="marker">IMPORTANT INFORMATION THAT NEEDS TO BE EMPHASIZED</span>
</p>
</div>
</body>
</html>