I am trying to align my text and text box to the center of a div. My main div is centered due margin:0 auto. But I applied this to the text box and didn't work.
<div class="CommentBox">
Some text :
<input type="text" />
</div>
CSS
.CommentBox {
width:400px;
height:50px;
background-color: #A12A1E;
color:White;
margin:0 auto;
}
input[type="text"] {
margin:10px auto;
}
http://jsfiddle.net/88pMc/
I have tried everything. As you can see the above code, I added margin:0 auto, but my code is still not working. The text box just does not center out.
Can anyone help me here. I am confused why this does not work, as everywhere I checked is margin:0 autosuggested for center alignment.
source
share