How to draw a heart using only the css properties and html?
I have came across few codes to draw it but couldn't understand why do they use the before and after properties
css code
.heart {
background-color: red;
height: 30px;
transform: rotate(-45deg);
width: 30px;
}
.heart:before,
.heart:after {
content: "";
background-color: red;
border-radius: 50%;
height: 30px;
position: absolute;
width: 30px;
}
.heart:before {
top: -15px;
left: 0;
}
How the before and after properties work?
Would be helpful if someone could come up with alternate approach :)
Edits:- I just wanted to know why do we use the before and after properties and how it helps in creating this heart shape.
Also I'm looking for some easy and simple code(using only css) to obtain this shape.