Solved

Text Box size

Posted on 2006-11-14
6
162 Views
Last Modified: 2010-04-09
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.
0
Comment
Question by:Richard Korts
6 Comments
 
LVL 19

Expert Comment

by:VoteyDisciple
ID: 17943179
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
 

Author Comment

by:Richard Korts
ID: 17943231
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
 
LVL 19

Expert Comment

by:VoteyDisciple
ID: 17943269
HTML:
<input type="text" name="whatever_name" class="whatever" />


CSS:
input.whatever {
    width: 1em;
}
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Accepted Solution

by:
gcmachel earned 500 total points
ID: 17944275
You can use inline stylesheet like this,

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

Regards - G.
0
 
LVL 1

Expert Comment

by:kurnia
ID: 17946066
Use maxlength if you want to limit numbers of characters.

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

Expert Comment

by:viveksg
ID: 17986314


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

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
REST endpoint query with a parameter 1 37
Google Tag Manager - Add Trigger Using Div class 22 56
HTML question 2 25
.CSS HTML Help 3 25
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question