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
321 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
ID: 11754550
input {
  width: 10em;
}

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

Author Comment

by:BruceCheng
ID: 11755326
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
ID: 11756476
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
ID: 11757548
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
ID: 11757601
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

"I want to put my photos online, but I don't want them stolen.  What settings should I use?" When You Put Photos Online First and foremost, any digital file published on the WWW can be copied, stored, modified, retransmitted, etc.  Remember Naps…
When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
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…

813 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

13 Experts available now in Live!

Get 1:1 Help Now