I am currently practicing CSS by following along with a Youtube tutorial by freecodecamp.org
My code is as follows:
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>
Now when I specify display: block in the p:: after pseudo-selector I am getting the expected output as follows
but when I omit the display: block property, the green box just disappears as below:
Does someone have an appropriate explanation for why this happens? What I was expecting was that the box will still be shown inline after the 'hello before and after pseudo-elements' but it is disappearing altogether...
Thanks in Advance for the help.
Kind Regards, Sohaib