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