Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling HTML5 input type number

I'm writing a form in HTML5. One of the inputs is type=number. I want the input to only show 2 digits but it seems to default to showing at least 5 digits, which takes up extra space. I've tried adding size="2" attribute, with no effect.

This the tag i'm using:

<input type="number" name="numericInput" size="2" min="0" max="18" value="0" /> 

What am I missing?

like image 802
Michael Lewis Avatar asked Aug 22 '12 04:08

Michael Lewis


People also ask

How do you change the input type number in HTML?

The size attribute specifies the visible width, in characters, of an <input> element. Note: The size attribute works with the following input types: text, search, tel, url, email, and password. Tip: To specify the maximum number of characters allowed in the <input> element, use the maxlength attribute.

How do you write input type numbers in CSS?

Styling Input Fields If you only want to style a specific input type, you can use attribute selectors: input[type=text] - will only select text fields. input[type=password] - will only select password fields. input[type=number] - will only select number fields.


1 Answers

HTML5 number input doesn't have styles attributes like width or size, but you can style it easily with CSS.

input[type="number"] {    width:50px; } 
like image 189
zak_mckraken Avatar answered Sep 22 '22 12:09

zak_mckraken