How to make center horizontal a HTML element?

Hi there

This is my jsfidddle.net
http://jsfiddle.net/vngx/075r2sqq/

How to make any html element center horizontal true?

thanks

margin: auto only works on block-level elements. E.g.

#demo_but{margin-left:auto;margin-right:auto; display:block}

However, Iā€™m not too keen on setting an input to block display. So the alternative would be to set a container to text-align: center instead.

The input button wants to be inside a container:

<!doctype html>
<html>
<head>
<style type="text/css">
   .tac  {text-align:center;}
</style>
</head>
<body>

<div class="tac">
   <input type="button" value="Submit"  />
</div>

</body></html>

Ninjared by @ralphm :frowning:

1 Like

thanks

this is working for me

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.