473,662 Members | 2,596 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Lenght of textfield is not consistence on difference browser

Any way to define the length of a textfield?

I have just set all the field with a width so that they look like clear

and easy to read,
However, When I see the page of mac os, They are totally not the result

in IE of FF,
Does there any way to define it absolutely?
I have already change the size attribute and set the width of the
input.
Thank you

Jul 26 '06 #1
8 2226
Cylix <cy*******@gmai l.comscripsit:
Any way to define the length of a textfield?
Several ways, but none of them works consistently. You are probably
referring to the width property, which might be suitable for the purpose if
there were a way to use a unit that corresponds to the "width of character".
But there isn't. In HTML, there is, in theory, since if you set <input
type="text" ... size="42">, the number 42 is treated so that the implicit
unit is "average width of characters". The bad news is that this unit has no
clear definition, and browsers interpret the situation in rather different
ways.

The bottom line is: use the size="..." attribute, but make its value
somewhat larger than you expect typical input to be.
I have just set all the field with a width so that they look like
clear and easy to read,
How did you do that? And do you mean that all fields have the same width?
That's not the idea. The idea is that the width also acts as a visual hint
about the kind of input expected.
However, When I see the page of mac os, They are totally not the
result in IE of FF,
It depends on how you have set the width.
Does there any way to define it absolutely?
It absolutely depends on what you mean by "absolutely ".
I have already change the size attribute and set the width of the
input.
The size attribute should always be set for a text input field. Setting the
width property in CSS tends to override that setting when CSS is enabled,
but why would you do that? You normally don't have more suitable units in
CSS than the implied unit used in HTML. Sometimes setting width="100%" is a
good choice, though.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Jul 26 '06 #2
In article <11************ **********@i3g2 000cwc.googlegr oups.com>,
Cylix <cy*******@gmai l.comwrote:
>Any way to define the length of a textfield?
Like this: <input type="text" width=40 ...[the rest goes here]>

I had a problem with a user ID textfield and a password textfield
appeared the same width in one browser but different widths in
another browser.

What I did was define a CSS class that made the textfields use a
monospace font. Then the lengths are consistent always, determined by
the width attribute in the input tag.

CSS:

..monotext {
font-family: "Lucida Console", Monaco, monospace;
font-size: 91%
}

HTML:

<input class="monotext " type="text" width=40 ...>

About the monotext class: Lucida Console and Monaco are attractive
monospace fonts on Windows and Mac platforms, easier on the eyes
than the default Courier. The font size attribute is unnecessary
but I have found all the browsers I test seem to use a default
monospace size that looks bigger than the normal text.

-A
Jul 26 '06 #3
axlq wrote:
>>Any way to define the length of a textfield?

Like this: <input type="text" width=40 ...[the rest goes here]>
I expect this is what the OP did and that is where the problem lies.
>
What I did was define a CSS class that made the textfields use a
monospace font. Then the lengths are consistent always, determined by
the width attribute in the input tag.
An alternate method is to set the width in CSS using px, or ems to have
it adapt to font size. This is consistent across browsers regardless of
font choice.

.input-width { width: 12em; }

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Jul 26 '06 #4
Jukka K. Korpela wrote:
The size attribute should always be set for a text input field. Setting the
width property in CSS tends to override that setting when CSS is enabled,
but why would you do that? You normally don't have more suitable units in
CSS than the implied unit used in HTML. Sometimes setting width="100%" is a
good choice, though.
Thanks, you do point out a work around method and I have done what I
expect to.

Jul 27 '06 #5
In article <oc************ *************** ***@giganews.co m>,
Jim Moe <jm************ ***@sohnen-moe.comwrote:
>axlq wrote:
>What I did was define a CSS class that made the textfields use a
monospace font. Then the lengths are consistent always, determined by
the width attribute in the input tag.
An alternate method is to set the width in CSS using px, or ems to have
it adapt to font size. This is consistent across browsers regardless of
font choice.

.input-width { width: 12em; }
That doesn't work as well for me, because an "em" unit isn't
consistent across browsers, and an "em" unit has little or nothing
to do with actual character width. My suggestion, on the other
hand, sets the width of the text box according to actual character
width of a monospace font, so it's consistent across all browsers to
the monospace font used by those browsers.

-A
Jul 27 '06 #6
axlq <ax**@spamcop.n etscripsit:
Like this: <input type="text" width=40 ...[the rest goes here]>
Why would you use invalid markup, instead of using the size attribute? The
width attribute is undefined in an <inputelement . What's worse, if some
browsers recognize it, who knows how they will treat it? They might use 40
pixels, or 40 characters, or something else.
I had a problem with a user ID textfield and a password textfield
appeared the same width in one browser but different widths in
another browser.
Quite catastrophic, is it not? Surely typical users viewed your page on both
browsers and were shocked at the different widths.
What I did was define a CSS class that made the textfields use a
monospace font.
Well, that's an approach that may help in the problem, but we know that it
(when it works - remember the usual CSS caveats) _creates_ a problem: user
input (as well as any prefilled content) will appear in a monospace font.
This is not typical and normal, so it may make the user wonder what is going
on. The problem might be tolerable, but before creating it, I would ask:
what is the original problem, really, and how much does it matter?
About the monotext class: Lucida Console and Monaco are attractive
monospace fonts on Windows and Mac platforms, easier on the eyes
than the default Courier.
Courier is a bitmap font that isn't used that much. Is it still the default
somewhere? I'd say Courier New (which looks rather similar to Lucida
Console) is more common.
The font size attribute is unnecessary
but I have found all the browsers I test seem to use a default
monospace size that looks bigger than the normal text.
Browsers generally use reduced font size for some elements, including
<input>, <codeetc. This is rather poorly documented and not a very good
idea. E.g., it is probably important that the user can see clearly the
characters he has typed. For <code>, the feature is understandable since
<codeis normally rendered in a monospace font, and this typically means
that it looks somewhat bigger than text in a proportional font with the same
font size.

So for <input>, I would rather treat the default size reduction as a problem
rather than as something I should imitate in my CSS code, so I normally use
font-size: 100% for input. Actually, on my computer, your suggested 91%
seems to make the font size _larger_ than without the setting (though not as
large as 100%), whereas 90% gives the default size. (This may sound odd, but
font size rounding effects can be odd.)

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Jul 27 '06 #7
In article <q%************ *******@reader1 .news.jippii.ne t>,
Jukka K. Korpela <jk******@cs.tu t.fiwrote:
>axlq <ax**@spamcop.n etscripsit:
>Like this: <input type="text" width=40 ...[the rest goes here]>

Why would you use invalid markup, instead of using the size attribute? The
width attribute is undefined in an <inputelement . What's worse, if some
Sorry, I meant size, not width. I make that mistake often in my own
markup, then catch it during validation.

Should I address your other comments? Oh, well, why not. This is
usenet after all.
>I had a problem with a user ID textfield and a password textfield
appeared the same width in one browser but different widths in
another browser.

Quite catastrophic, is it not? Surely typical users viewed your page on both
browsers and were shocked at the different widths.
Indeed, the effect was quite visually jarring. You wouldn't believe
how much it bothered me. I feel so much better now for having fixed
it. Now my users won't be asking why I'm incapable of rendering a
userID and password field the same length.
>What I did was define a CSS class that made the textfields use a
monospace font.

Well, that's an approach that may help in the problem, but we know that it
(when it works - remember the usual CSS caveats) _creates_ a problem: user
input (as well as any prefilled content) will appear in a monospace font.
That's perfectly acceptable for a login and password field.
>Courier is a bitmap font that isn't used that much.
Wrong, Courier is the name of a typeface that pre-dates the web. I
used the term in that general context. Of course, Courier New is
the scalable non-bitmap variety.
>I'd say Courier New (which looks rather similar to Lucida
Console) is more common.
Courier New looks nothing like Lucida Console.
>The font size attribute is unnecessary
but I have found all the browsers I test seem to use a default
monospace size that looks bigger than the normal text.

Browsers generally use reduced font size for some elements, including
<input>, <codeetc.
Generally yes. But as soon as you define the size as 1em, the monospace
font looks disproportionat ely large on all browsers I tested. So I use
0.91em. This brings it down to a comparable size, and if any browser
wants to define 1em for a monospace font as something smaller than what
I've set, then 91% of that won't be a big difference.
>So for <input>, I would rather treat the default size reduction as a problem
rather than as something I should imitate in my CSS code, so I normally use
font-size: 100% for input. Actually, on my computer, your suggested 91%
seems to make the font size _larger_ than without the setting (though not as
large as 100%), whereas 90% gives the default size. (This may sound odd, but
font size rounding effects can be odd.)
Yes, I noticed that too. Opera tends to make all text smaller than
other browsers by default, so I settled on 91% as a good value that
shows up large enough in Opera but still slightly smaller than 100%
in other browsers.

-A
Jul 28 '06 #8
axlq wrote:
>>
.input-width { width: 12em; }

That doesn't work as well for me, because an "em" unit isn't
consistent across browsers, and an "em" unit has little or nothing
to do with actual character width.
True. It is based on character height. See
<http://www.w3.org/TR/CSS21/syndata.html#em-width>. It certainly produces
a much more consistent result than using the "size" attribute for <input>.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Jul 28 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2295
by: C. Armour | last post by:
Help me, I'm suffering! Situation: I have a load() function which loads a bunch of TextFields with values. There are TextListeners registered for each of these TextFields. Thus, changing the text in any of them fires off a TextEvent, even if done programmatically (by means of setText()). The problem: I need all the various TextEvents fired off during the load operation (as a result of using TextField.setText())
300
18285
by: Ståle Sæbøe | last post by:
I am a bit curious about this. The graphic design people I work with say it is their preferred font for web pages. The reason being that it is "kinder" to the eye both in terms of shape and size. The HTML "hardcore elititst" profess that it is a useless font because it is too big compared to other fonts. Personally I do not care one way or the other, but I generally trust
13
9608
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be assigned to a variable and output using document.write. (Note, there is no submit button or other form elements. Basically
12
7303
by: Pudlik, Szymon | last post by:
Hi, I've written some code: function onSubmit(form){ for (var i = 0; i < form.elements.lenght; i++){ if (form.elements.disabled == 1) form.elements.disabled = 0; }
1
3176
by: Suresh | last post by:
How do I insert a char into the textfield on the keypress event of another textfield? I have two textboxes, "text1" and "text2". Important: "text1" is outside the table. "text2" is inside the table cell. On the keydown/keypress/keyup event of "text1", the character which I entered in the "text1" must display in the textfield "text2".
0
5507
by: Jean-Michel POURE | last post by:
Dear friends, I studying the possibility to port Compiere CRM from Oracle to PostgreSQL. As Compiere evolves nearly everyday in CVS, I would like to run the Oracle code without (too much) modification. Don't blame me, I know using search/replace works most of the times. At first, I used CREATE TYPE syntax to map Oracle nvarchar2 to PostgreSQL varchar type (see code #1). The code seems to be the equivalent of:
3
5612
by: Sidney Linkers | last post by:
Hi, I'm trying to make a calculated text field in a query where the textvalue is being populated from multiple records. I already use a VBA function to loop through records and concatenate the text. It works but the performance is really bad. I'm looking for a solution in plane SQL, so the looping is done by joining tables. I can't get it to work....
9
1790
by: Andrey Koptyaev | last post by:
What does it mean "fieldRequired.lenght" in php 4.1 ? I know "fieldRequired->lenght" but don't know "fieldRequired.lenght" Please help to understand. Thank you!
18
18078
by: Erich Meier | last post by:
Hello there, is there any way to set the size of images or table cells in HTML not by pixels but by inches or in millimetres? The problem behind this is that you never know what kind of output device the consumers of your webcontent may use. For example they may use computer screens, but in different sizes and with different resolutions. That means, on one computer screen a single pixel has a different size than on another. Just...
0
8435
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8768
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8547
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5655
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4348
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.