473,395 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

size attribute of input element: characters not fixed width?

The W3C HTML standard sais the following concerning the HTML input
element:

<quote>
size = cdata [CN]
This attribute tells the user agent the initial width of the control.
The width is given in pixels except when type attribute has the value
"text" or "password". In that case, its value refers to the (integer)
number of characters.
</quote>

However, it seems I cannot specify an input element with a size of
two,
as my web browser keeps making the input element wider than specified
in terms of characters. Maybe it's cause the characters are not fixed
width. Feedback appreciated,

Best Regards,

Neil
Jul 23 '05 #1
2 6364
Previously in comp.infosystems.www.authoring.html, Neil Zanella
<nz******@gmail.com> said:
However, it seems I cannot specify an input element with a size of
two,
as my web browser keeps making the input element wider than specified
in terms of characters.


What browser? What URL?

--
Mark Parnell
http://www.clarkecomputers.com.au
Jul 23 '05 #2
nz******@gmail.com (Neil Zanella) wrote:
However, it seems I cannot specify an input element with a size of
two, as my web browser keeps making the input element wider than
specified in terms of characters.


Setting width in terms of a number of characters is very vaguely defined,
since in most fonts, the widths of characters vary. A common interpretation
is that the _average_ width should be used, though some browsers use
_maximum_ width - which is generally regarded as a flaw. But "average"
isn't well defined either. Average over what? The Unicode character
repertoire? Some other repertoire? With or without weights based on
frequency of characters? (If you calculate the average over all Ascii
letters, you get something that is much bigger than average width in normal
text, since half of Ascii letters are uppercase and typically fairly wide.)

So there is no good answer. I have even seen browsers that implement
<input size="2"> as a box that cannot even accommodate _one_ letter "W".

If you wish to set the width to give a hint of the expected number of
characters (e.g., when asking for a day of month), setting the font to
monospace is probably the best shot. Not 100% safe of course, but at least
it is fairly well defined what a browser _should_ do, since the maximum
width is the same as (any) average width! (The font is best set using CSS,
though a few old browsers might obey <tt><input ...></tt>.)

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 23 '05 #3

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

Similar topics

35
by: wired | last post by:
Hi, I've just taught myself C++, so I haven't learnt much about style or the like from any single source, and I'm quite styleless as a result. But at the same time, I really want nice code and I...
6
by: Csaba2000 | last post by:
How do I detect when the font size has been changed (especially by user action: either Ctrl+Scroll wheel or View/Text Size)? This is just for use on IE 5.5+, but it would be great if there was a...
2
by: Kai Grossjohann | last post by:
I would like to put a text input field (in the sense of <input type="text">) and an image next to each other, where I know the size in pixels of the image, and I know the total width in em. I...
4
by: Martin Lucas-Smith | last post by:
I am wanting to know whether are XHTML1-valid characters for use within an id attribute and/or a name attribute. ...
2
by: Elmo Watson | last post by:
In HTML - for a textbox (input), I would use the 'Size' Attribute In an ASP.Net TextBox - I use 'Width' - - (like 200px) However, for other browsers - Other than IE - the size attribute isn't...
8
by: Jack | last post by:
Hi, I have a asp page where multiple rows for a client is generated using asp. Some of these are combo boxes and some are text and are coming from a recordset. Now, the following is the code to...
17
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I find the size of a browser window?...
18
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin,...
19
by: Chad | last post by:
Okay, let's say I have an exotic os that limits how much goes to stdout. When I go like.. #include <stdio.h> int main(void) { int i=0; for(i=0; i< 10; i++) { printf("a \n");
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.