I'm currently honing my CSS skills by following a Youtube tutorial from freecodecamp.org
Here's the code I've been working on:
p::before{
content: "hello ";
color: white;
font-size: 60px;
background: salmon;
margin-bottom: 20px;
}
p::after{
display: block;
content: "";
height: 100px;
width: 100px;
background: green;
}
<p>Before and after pseudo elements</p>
When adding 'display: block' to the p::after pseudo-selector, the result is as expected:
https://i.sstatic.net/lEgx5.png
However, when omitting the 'display: block' property, the green box disappears completely:
https://i.sstatic.net/JVKPM.png
Can anyone shed some light on why this happens? I thought the box would still appear inline after the text but it vanishes instead...
Thanks in advance for any guidance.
Sincerely, Sohaib