Is there a css or html attribute to center the contents of the input tag?

This is probably best explained by the visual.

As shown below, I have two <input> elements for the user to enter a date.

alt text

Is there a CSS or HTML attribute that allows me to centralize the content (in my case, dates) horizontally in the displayed input areas instead of left-aligned?

Note. I am not trying to align the controls myself, only what is inside them.

+4
source share
2 answers
 <input type="text" style="text-align:center;" /> 
+4
source

Use text-align: center

CSS

 input.date { text-align: center; } 

HTML

 <input class="date" type="text" value="123" /> 

See jsfiddle .

0
source

All Articles