right-aligned form buttons

Up until recently I relied upon floating form buttons or elaborate text alignment scenarios to get them to sit at the bottom right of a form. I’ve just discovered that a better method exists and is in fact so glaringly obvious I’m surprised I’ve not come across it before.

If you give your input button a class of btn, all that’s required is:

input.btn {
margin-right:5px;/*or any value*/
margin-left:auto;
display:block;
}

that’s it! of course, if you where being fancy (and didn’t care about ie) you could use input[type=submit] in place of the class selector.

I think i may write an article purely about form layout in the not too distant future. I’ve been styling forms for a few years now and it seems that with each new site i discover an improvement to my previous method. If it’s something people would be interested just let me know and it might encourage me to do it sooner rather than later.

Leave a Reply