Centering a Twitter Bootstrap button

If you don’t mind a bit more markup, this would work:

class="centered"> class="btn btn-large btn-primary" type="button">Submit

With the corresponding CSS rule:


I have to look at the CSS rules for the btn class, but I don’t think it specifies a width, so auto left & right margins wouldn’t work. If you added one of the span or input- rules to the button, auto margins would work, though.


Confirmed my initial thought; the btn classes do not have a width defined, so you can’t use auto side margins. Also, as @AndrewM notes, you could simply use the text-center class instead of creating a new ruleset.

Even better you could use bootstraps text-center class and not have to write any css yourself. for example


–  andrewmilson May 17 ’14 at 23:30


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s