views:

27

answers:

2

This is probably best explained with a visual.

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

alt text

Is there a CSS or HTML attribute that will allow me to center the contents (in my case, the dates) horizontally in the displayed input areas instead of left-aligning them?

Note: I am not trying to align the controls themselves, just what is inside them.

+3  A: 
<input type="text" style="text-align:center;" />
Novikov
+1 - I don't believe the OP said there was anything wrong, he just doesn't know about this rule, so this could be phrased a little better :)
Nick Craver
Bad wording on my part, I assumed something with the calendar was breaking CSS.
Novikov
The only thing wrong with it is that it is late in the day, and my brain must have locked up on me. Can't believe I couldn't remember that attribute, I've used it dozens of times! Is this how Alzheimer's starts?
JohnFx
A: 

Use text-align: center

CSS

input.date {
    text-align: center;
}

HTML

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

See in jsfiddle.

Topera