Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Size of input and textarea

Reply
Thread Tools

Size of input and textarea

 
 
Jens Müller
Guest
Posts: n/a
 
      10-10-2008
Hello,

I have two html tags <input> and <textarea> and want them to have the same
width. I use size=x and rows=x respective but they are not the same width
and, even if I chose the numbers that it fits, different browsers show them
in idfferent sizes.

Why is this? Would css be the best practice to achieve same witdth?

Thanks!

 
Reply With Quote
 
 
 
 
Neredbojias
Guest
Posts: n/a
 
      10-10-2008
On 10 Oct 2008, Jens Müller <(E-Mail Removed)> wrote:

> Hello,
>
> I have two html tags <input> and <textarea> and want them to have the
> same width. I use size=x and rows=x respective but they are not the
> same width and, even if I chose the numbers that it fits, different
> browsers show them in idfferent sizes.
>
> Why is this?


Because you're not doing it right. I would tell you _how_ you're not
doing it right but you didn't supply a url or even any data, did you?

--
Neredbojias
http://www.neredbojias.org/
Great Sights and Sounds
 
Reply With Quote
 
 
 
 
Adrienne Boswell
Guest
Posts: n/a
 
      10-10-2008
Gazing into my crystal ball I observed Jens Müller <(E-Mail Removed)>
writing in news:48ef5fbd$0$6588$(E-Mail Removed)-online.net:

> Hello,
>
> I have two html tags <input> and <textarea> and want them to have the
> same width. I use size=x and rows=x respective but they are not the
> same width and, even if I chose the numbers that it fits, different
> browsers show them in idfferent sizes.
>
> Why is this? Would css be the best practice to achieve same witdth?
>
> Thanks!
>
>


Yes, CSS would be the way to go. Remember that HTML cannot constrain
the number of characters in a textarea element, that can only be
reliably done server side (although one can truncate input, and advise
remaining characters with client side javascript).

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

 
Reply With Quote
 
Jens Müller
Guest
Posts: n/a
 
      10-10-2008
>> Why is this?
>
> Because you're not doing it right. I would tell you _how_ you're not
> doing it right but you didn't supply a url or even any data, did you?


What's this strange kind of answer?
There exist only the hmtl attributes rows and size for textarea and input
(type=text). Apparently, these are not renered in the same width when
setting them to the same value, so I'm asking whetere one should use css to
set the width or perhaps if there exists some other attribute like <textarea
realsize="x">...


 
Reply With Quote
 
Chris F.A. Johnson
Guest
Posts: n/a
 
      10-10-2008
On 2008-10-10, Jens Müller wrote:
> Hello,
>
> I have two html tags <input> and <textarea> and want them to have the same
> width. I use size=x and rows=x respective but they are not the same width
> and, even if I chose the numbers that it fits, different browsers show them
> in idfferent sizes.
>
> Why is this? Would css be the best practice to achieve same witdth?


Yes, use CSS. (And provide a URL if you need more help.)

--
Chris F.A. Johnson, webmaster <http://Woodbine-Gerrard.com>
================================================== =================
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
 
Reply With Quote
 
Jonathan N. Little
Guest
Posts: n/a
 
      10-10-2008
Jens Müller wrote:
>>> Why is this?

>>
>> Because you're not doing it right. I would tell you _how_ you're not
>> doing it right but you didn't supply a url or even any data, did you?

>
> What's this strange kind of answer?
> There exist only the hmtl attributes rows and size for textarea and
> input (type=text). Apparently, these are not renered in the same width
> when setting them to the same value, so I'm asking whetere one should
> use css to set the width or perhaps if there exists some other attribute
> like <textarea realsize="x">...


It won't help to make stuff up. Why not look at the spec?

http://www.w3.org/TR/html4/interact/...#edef-TEXTAREA

Now as the others of said, form controls have limited styling from
browser to browser. What you are witnessing is that browsers reserve
space for a scroll bar in TEXTAREAs, Gecko does show the scroll bar
until needed whereas IE and Opera show a disabled one. Now SIZE is an
optional attribute for INPUTs bit ROWS and COLS are not for TEXTAREAs.
And a UA may use a proportional font for controls. Set your required
attributes then override them in your stylesheet.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta http-equiv="content-language" content="en-us">

<title>template</title>

<style type="text/css">
..conformDammit {
display: block; font: 1em normal, monospace; width: 15em;
}
</style>

</head>
<body>
<form>
<div>
<input type="text" class="conformDammit">
<textarea rows="5" cols="30" class="conformDammit"></textarea>
</div>
</form>
</body>
</html>






--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
 
Reply With Quote
 
Jens Müller
Guest
Posts: n/a
 
      10-10-2008
> http://www.w3.org/TR/html4/interact/...#edef-TEXTAREA
> ...
> And a UA may use a proportional font for controls. Set your required
> attributes then override them in your stylesheet.


Thaks, helpful.

Jens
 
Reply With Quote
 
freemont
Guest
Posts: n/a
 
      10-12-2008
On Fri, 10 Oct 2008 15:59:01 +0200, Jens Müller writ:

> Hello,
>
> I have two html tags <input> and <textarea> and want them to have the
> same width. I use size=x and rows=x respective but they are not the same
> width and, even if I chose the numbers that it fits, different browsers
> show them in idfferent sizes.
>
> Why is this? Would css be the best practice to achieve same witdth?
>
> Thanks!



Something I stumbled upon that might interest you:

<input type="text" name="name" id="name" value="" maxlength="50"
style="width:100%">
<textarea name="comments" id="comments" rows="0" cols="0"
style="width:100%;height:10em">

Just forget about the size attribute in <input> and use css to size it.
The <textarea> requires rows and cols, but set them to zero and again
size with css. Validates fine and seems to work cross-browser.

--
"Because all you of Earth are idiots!"
¯`·.¸¸.·´¯`·-> freemont© <-·´¯`·.¸¸.·´¯
 
Reply With Quote
 
Bergamot
Guest
Posts: n/a
 
      10-13-2008

freemont wrote:
>
> Just forget about the size attribute in <input> and use css to size it.
> The <textarea> requires rows and cols, but set them to zero and again
> size with css.


You forget that CSS is supposed to be optional. While the size attribute
is optional for input elements, there is no reason to set rows/cols to 0
for textareas, nor should they be. You can still use CSS to fine tune
sizes, but the cols/rows attributes should be reasonable fall-back values.

> Validates fine and seems to work cross-browser.


Did you try that 0 cols and rows in Lynx, or with CSS disabled?

--
Berg
 
Reply With Quote
 
freemont
Guest
Posts: n/a
 
      10-13-2008
On Sun, 12 Oct 2008 23:18:21 -0500, Bergamot writ:

> You forget that CSS is supposed to be optional. While the size attribute
> is optional for input elements, there is no reason to set rows/cols to 0
> for textareas, nor should they be. You can still use CSS to fine tune
> sizes, but the cols/rows attributes should be reasonable fall-back
> values.


Good point! Thanks.

--
"Because all you of Earth are idiots!"
¯`·.¸¸.·´¯`·-> freemont© <-·´¯`·.¸¸.·´¯
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Preferred Size, Minimum Size, Size Jason Cavett Java 5 05-25-2008 08:32 AM
How to add </textarea> within <textarea> tags? frank.moens@gmail.com Javascript 1 07-04-2007 04:00 PM
mega pixels, file size, image size, and print size - Adobe Evangelists Frank ess Digital Photography 0 11-14-2006 05:08 PM
Textarea Inside of a textarea wperry1@gmail.com ASP General 6 02-05-2006 08:00 AM
Removing carriage returns from <textarea></textarea> input Augustus ASP General 1 09-10-2003 04:55 AM



Advertisments