Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to limit input text length using CSS3? [duplicate]

Tags:

html

css

input

Possible Duplicate:
Can I specify maxlength in css?

In my CSS I use this code to make round borders for all the input tags in my site. I wonder if it is possible to limit the lenght of the input in the same way (for example 50 characters)

input  
{ 
border-radius: 10px;
-moz-border-radius: 10px;
-khtml-border-radius: 10px;
-webkit-border-radius: 10px;
}

I imagine something like (this is not working):

input
{
max-lenght: 50;
} 

Any sugestions? Thank you very much!

EDIT: This question is about how many characters can the user write into the field, not the visible size of the input

like image 909
yenssen Avatar asked Nov 20 '12 23:11

yenssen


People also ask

How do I limit input length in CSS?

Complete HTML/CSS Course 2022 To give a limit to the input field, use the min and max attributes, which is to specify a maximum and minimum value for an input field respectively. To limit the number of characters, use the maxlength attribute.

How do I restrict text length in HTML?

You can specify a minimum length (in characters) for the entered value using the minlength attribute; similarly, use maxlength to set the maximum length of the entered value, in characters.


1 Answers

You cannot use CSS to limit the number of input characters. That would be a functional restriction, and CSS deals with presentation.

like image 133
Jukka K. Korpela Avatar answered Oct 09 '22 17:10

Jukka K. Korpela