user1937021
user1937021

Reputation: 10771

Horizontally center align inline html element

Ok so I have a an anchor element within a div with a fixed width, the anchor element needs to remain inline because the text that it holds is dynamic and it has a background because it is a button. I want the background of the button to only be the size of the length of text too. Is there a way to do so?

<div class="wrap">
<a class="button>Start »</a>
</div>



 .wrap{
     width:900px;
background:white;
    }

    a{
    display:inline;
background:black;

    }

Upvotes: 0

Views: 104

Answers (1)

Johan
Johan

Reputation: 19062

I think

.wrap{
    width:900px;
    text-align: center;
}

will do the trick

See

http://jsfiddle.net/jEsRG/3/

Upvotes: 1

Related Questions