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
326 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

Unordered lists (HTML ul tags) are very handy to create menus of all types, shapes and sizes.  All it takes is a little knowledge of CSS and the possibilities are endless. First off, you should know the general format for menus created using the …
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
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…

828 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