Sourav Sourav - 10 months ago 78
CSS Question

Place a button right aligned

I use this code to right align a button.

<p align="right">
<input type="button" value="Click Me" />
</p>


But P tags wastes some space, so looking to do the same with span or div.

Answer Source

Which alignment technique you use depends on your circumstances but the basic one is float: right;:

<input type="button" value="Click Me" style="float: right;">

You'll probably want to clear your floats though but that can be done with overflow:hidden on the parent container or an explicit <div style="clear: both;"></div> at the bottom of the container.

For example: http://jsfiddle.net/ambiguous/8UvVg/