Steven
Steven

Reputation: 18859

Vertically align text on one line or two lines within a link

I have an anchor tag with some text:

<a href="">My Link</a>

with this styling so that it will look vertically aligned within a 30px high link:

a
{
    width: 90px;
    padding: 13px 0 13px 0;
}

The problem is that now there is longer text that doesn't fit in the 90px wide link, so it's causing it to wrap. So the text in the link is pushed down farther, and not vertically aligned within the anchor tag.

Anyone know how I can make sure a link is vertically aligned for text on one or two lines? I don't have the ability to add a class to any links with two lines.

Upvotes: 0

Views: 133

Answers (2)

Mr. Alien
Mr. Alien

Reputation: 157324

Text doesn't wrap for me

http://jsfiddle.net/mTJDd/

If you want to vertically align any text, the correct way is to use line-height property

Demo 2

Upvotes: 1

Sachin
Sachin

Reputation: 40970

Try to use line-height property.

a
{
   line-height:25px;
}

Upvotes: 1

Related Questions