Link to home
Start Free TrialLog in
Avatar of Richard Korts
Richard KortsFlag for United States of America

asked on

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.
Avatar of VoteyDisciple
VoteyDisciple

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.
Avatar of Richard Korts

ASKER

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

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


CSS:
input.whatever {
    width: 1em;
}
ASKER CERTIFIED SOLUTION
Avatar of gcmachel
gcmachel

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Use maxlength if you want to limit numbers of characters.

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


<input type="text" name="txtTest" style="width: 1em;" />