The <input> tag: should one use "width" or "size"?

A

aaronfude

Hi,

What's a better way to control the width of an input box? To use
"width", as in style="width: 200px", or size as in <input size=25>?

Thanks!

Aaron Fude
 
J

Jukka K. Korpela

Scripsit (e-mail address removed):
What's a better way to control the width of an input box? To use
"width", as in style="width: 200px", or size as in <input size=25>?

Surely the latter, since as an author, you can estimate the typical length
of input in characters but not in pixels. For all that you can know, 200px
might correspond to 4 or 40 characters.
 
A

Adrienne Boswell

Scripsit (e-mail address removed):


Surely the latter, since as an author, you can estimate the typical
length of input in characters but not in pixels. For all that you can
know, 200px might correspond to 4 or 40 characters.

Agreed, as well as, as an author you may need to limit the user to a
certain number of characters, if for instance, the information is to be
posted to a database. Of course, in that case, you would also want to
check the size of the data server side.
 
J

Jukka K. Korpela

Scripsit Adrienne Boswell:
Agreed, as well as, as an author you may need to limit the user to a
certain number of characters, if for instance, the information is to
be posted to a database. Of course, in that case, you would also
want to check the size of the data server side.

And then you would also want to use the attribute maxlength="25", which will
limit the amount of characters. Browsers enforce this, but it still cannot
be relied on, since a user could create a copy of the page with that
attribute removed.
 
S

Sherm Pendley

Jukka K. Korpela said:
And then you would also want to use the attribute maxlength="25",
which will limit the amount of characters. Browsers enforce this, but
it still cannot be relied on, since a user could create a copy of the
page with that attribute removed.

.... or submit the form with something that isn't a browser. :)

sherm--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top