Solved

Why after I added style sheet definitions for INPUT tag, my text boxes on all web pages get bigger?

Posted on 2004-08-09
5
312 Views
Last Modified: 2008-03-06
After I added style sheet for INPUT tag like this:

INPUT
{
      font-size: 10pt;
      font-family: Arial
}

All text boxes in my web pages get much bigger even after I specified the size and maxlength for all of my text boxes.

Does anybody know what attribute I need to add to this INPUT style sheet to fix this problem? I don't want to go to every text boxes to specify the width in style sheet format.

Thanks a lot.
0
Comment
Question by:BruceCheng
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:arantius
Comment Utility
input {
  width: 10em;
}

Substitute for 10 whatever value suits your fancy.
0
 
LVL 1

Author Comment

by:BruceCheng
Comment Utility
I tested it. I doesn't work as expected. I tried use 10em, 1em, 5em ... But on my web pages, some text boxes are changed to very big. Some text boxes are changed to very small. Looks like the SIZE and MAXLENGTH attribute of my textboxes are not functioning any more.

Are there any other suggestions?

Thanks a lot.
0
 
LVL 2

Expert Comment

by:MGrassman
Comment Utility
If you have some code or a webpage I could reference, it would allow me to narrow the problem down for you.

Michael
{personal website url removed - ee_ai_construct, cs moderator}
0
 
LVL 1

Author Comment

by:BruceCheng
Comment Utility
The following is the code sample. You can notice that by adding and removing the <style> block, the widthes of the text boxes are changed too. And adding in the "width: 10em" only makes things worse.

My question is, how can I make the text boxes only wide enough to hold the number of characters specified by maxlengh by using that global style sheet. Or at least the width of the text box should be the same as without using the style sheet. Thanks.

<html>
<head>
<title></title>
<style>
INPUT
{
     font-size: 10pt;
     font-family: Arial
}
</style>
</head>
<body>
<input type="text" size="20" value="This is just for testing"> <br>
<input type="text" size="2" maxlength="2">
</body>
</html>
0
 
LVL 2

Accepted Solution

by:
MGrassman earned 50 total points
Comment Utility
For every input box you have that you don't want to be a custom size take out the size attribute and use the width property of css.  Your maxlength attribute will still function correctly.  

Hope this helps.


<html>
<head>
<title></title>
<style>
      INPUT{ 
               font-size: 10pt;
               font-family: Arial
               width:10em;
      }
</style>
</head>
<body>
<input type="text"  value="This is just for testing">
<input type="text" maxlength="2">
</body>
</html>
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now