Block element, horizontal center aligned and minimum width possible

Posted by Nazgulled on Stack Overflow See other posts from Stack Overflow or by Nazgulled
Published on 2010-04-01T22:10:08Z Indexed on 2010/04/01 22:13 UTC
Read the original article Hit count: 353

Hi,

I'm trying to have this block element to be horizontally aligned in the middle but at the same time I would like the width to be the minimum possible for the contents inside. But I don't think it's possible or I'm not able to do it myself...

a#button-link {
    background: url("images/button-link.png") no-repeat scroll center left;
    margin: 12px auto 0 auto;
    display: block;
    width: 125px;
    height: 32px;
    line-height: 32px;
    padding-left: 35px;
    font-weight: bold;
}

This is my current code... The idea behind this is that the text for that tag could be slightly bigger or smaller depending on the user language and how much characters the same sentence has for that specific user's language. There's no way I can control but I still would like to have this element horizontally aligned to center.

Is this possible with CSS?

© Stack Overflow or respective owner

Related posts about XHTML

Related posts about horizontal-alignment