CSS Vertically Align Text

T

Trevor

Note the following html code:

<div id="linkbar">
<p>
links
</p>
</div>

Now take a look at this CSS:

#linkbar {
height: 30px;
text-align: center;
}

#linkbar p {
vertical-align: middle;
}

Why isn't the text in the div aligned vertically? What's the best way
to do what I want?

Thank you,
Trevor
 
B

Barbara de Zoete

Note the following html code:

<div id="linkbar">
<p>
links
</p>
</div>

Now take a look at this CSS:

#linkbar {
height: 30px;
text-align: center;
}

#linkbar p {
vertical-align: middle;
}

Why isn't the text in the div aligned vertically?

Vertical align is a property that works with table cells only.

What's the best way
to do what I want?

Add display:table-cell; to the selector #linkbar p
 
N

Neredbojias

Note the following html code:

<div id="linkbar">
<p>
links
</p>
</div>

Now take a look at this CSS:

#linkbar {
height: 30px;
text-align: center;
}

#linkbar p {
vertical-align: middle;
}

Why isn't the text in the div aligned vertically? What's the best way
to do what I want?

Add this line to #linkbar p {

line-height: 30px;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top