DEV Community

Discussion on: 4 Things I Learned From Building My First Site Solo

Collapse
 
clairemuller profile image
Claire Muller

I was originally setting the line-height equal to height, but if the text is too long and wraps to the next line, it creates a huge space between the two lines. :(

Collapse
 
yaser profile image
Yaser Al-Najjar

Ah, line-height is for one line text... here the multi-line way:

It's like converting this paragraph into a table (using display), so that we can use vertical-align

<style>
    p {
        background-color: red;
        width: 150px;
        height: 150px;
        display: table-cell;
        vertical-align: middle;
    }
</style>

<p>whatever stuff right here to go to the next line</p>