Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
347 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 150 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
Suggested Courses

715 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