Text Box size

In an HTML form when using input type="text", I want the size to be very small.

When I put size="1", it still allows 4 or 5 characters to be typed into the box.

Is there any way to make it smaller in width than size="1"?

I relaize that maxlength can limit the number of characters typed in. It's more the width on the form that is sometimes an issue.
Richard KortsAsked:
Who is Participating?
 
gcmachelCommented:
You can use inline stylesheet like this,

<input type="text" name="whatever_name" class="whatever"  style="width: 1em;" />

Regards - G.
0
 
VoteyDiscipleCommented:
You're better off in this situation controlling the physical size of the box through your stylesheet.  A simple rule like:

input.whatever {
    width: 1em;
}

... (adjusting the width to something you like) is all you'd need.
0
 
Richard KortsAuthor Commented:
To VoteyDisciple,

Can you be more specific? I don't understand what you mean. I need to see both the stylesheet code AND the <input type....> code.

Please gove me a specific example.

Thanks

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
VoteyDiscipleCommented:
HTML:
<input type="text" name="whatever_name" class="whatever" />


CSS:
input.whatever {
    width: 1em;
}
0
 
kurniaCommented:
Use maxlength if you want to limit numbers of characters.

<input type="text" size="1" maxlength = "1" style="width: 1em;" />
0
 
viveksgCommented:


<input type="text" name="txtTest" style="width: 1em;" />
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.