views:

252

answers:

1

I have a page that visually has two fields right on top of each other, but are actually in two different forms.

In Firefox, they appear to have the same width. In IE (IE6, IE7, IE8) they appear with different widths.

Here's a sample, I think the problem is the lack of "size="

<input id="fieldid" type="text"  name="fieldname" value="" />

When you do this (without a size), what is the size?

I found some docs on HTML3 and HTML4...

but could not get a clear idea if what the default value should be.

From playing with Firebug in Firefox 3.0, it looks like it is 20 in Gecko.

In IE, it looks variable, based on some other conditions I do not understand.

UPDATE:

I did try to compare the two form's characteristics further, but was unable to isolate the variable. I did hack the file to make the both use set size=20, but the widths are still different (although less than before).

+3  A: 

In IE6 and 7 it also appears to be 20. Without knowing more about your test conditions or results, it's difficult to say why you are experiencing "variable" default sizes.

The "size" attribute will always be rendered relative to the font size set in style. E.g. "20" at size 10 font is different than "20" at size 20 font, since "size" is relative to character widths. If you want a hard/static width, use the width css property.

Rex M
Can you tell me how you confirmed the value is 20? Did you check the DOM via Javascript?
benc
@benc I compared the rendered textbox to one which was explicitly set to 20. Always rendered the same, so clearly internally it uses 20 at render time.
Rex M
Ah. I had not thought of that. (sad)
benc