I don't want to modify the markup and I just want to know the reason behind the pseudo element that's how it works.
code demo
div{
border: 1px solid #000;
height: 300px;
}
div:before{
content: "";
height: 100%;
display: inline-block;
vertical-align: middle;
}
and narrowing the browser:
So, why just one line of paragraph is getting aligned? If you try to use vertical-align: bottom;
then you can see it would be at bottom and all lines of the paragraph would be there.
But I'm just curious to know why just one line of them is working with vertical align?