[thelist] CSS ? size of text input

Michael Collins mcollins at kuwago.com
Wed Feb 21 18:35:42 CST 2001


At 12:13 AM -0500 2/21/01, aardvark wrote:
>well, the 'width' attribute is supposed to be based on the number of
>characters, and as a result is dependent on things like <font> tags,
>CSS, user preferences, etc....
>
>i'd try using a % of the container first, and if that doesn't work, well,
>i dunno...
At 10:20 AM +0000 2/21/01, Peter-Paul Koch wrote:
>You can't calculate it, just tweak both values until it looks the 
>same in both browsers.
>
>ppk


The problem is that what I am after is to use this with a CGI 
application that will be substituting various character lengths for 
the input, and I want to also include the corresponding width for the 
CSS. The code must work for a variety of situations so a percentage 
is out of the question. I had thought that one of the relative 
measurements would work like "em" because that is defined to be the 
value of the font-size for a font but that is the height not width.


At 11:56 AM -0500 2/21/01, Bryce Johnson wrote:
>The way that we deal with it at our firm is to
>
><input type="text" name="field" value="" size="30" style="width:300px;">
>
>Netscape 4 will ignore the style attribute and go with the size, so we use
>SIZE= for netscape
>
>IE4+ will readthe style attribute and overide the size= with the style=, so
>we use STYLE="width:;" for IE
>
>bryce


That is more or less part of what I am after, to use both the size 
for non-CSS browsers and a style width for CSS. But I would like them 
to be at least roughly the same. The layout is not pixel perfect, 
within a half inch is good enough!

At 9:34 PM +1000 2/21/01, Adrian Fischer wrote:
>Some on asked this before and the response I used was this:
>
>input { font-family: Courier; font-size: 14px;  }
>
this is a fixed width font and displays the samein ie and ns.


So given a character size of 30 and a known font-size: 14px you know 
what about the width to calculate the corresponding width? I guess 
what I am hearing is that there is no calculation? How does a Web 
browser know how wide to make a text box when they are told its 30 
characters wide and of a given font metrics?

Thanks for the help

Michael


At 8:59 PM -0800 2/20/01, Michael Collins wrote:
>I want to specify the width of a text input on a form using the CSS 
>width property. I am used to specifying with a character length such 
>as:
>
><input type="text" name="field" value="" size="30">
>
>How do I calculate from a size specified by the HTML size attribute 
>to the CSS width so it will appear the same size as in:
>
><input type="text" name="field" value="" size="30" style="width:?;">
>




More information about the thelist mailing list