Spaces Cause Strange Behavior in TextArea
July 27, 2007 10:39 AM   Subscribe

At least in Firefox I'm seeing an undesirable behavior in textareas. My question is how to fix/avoid it. Here's the problem. Go to a textarea in Firefox. (The ask.metafilter ask a question one will do fine.) Type enough characters to fill a whole line of the textarea e.g., kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk... Now put a single space in front of that line. It moves the line one line lower instead of just putting a space in front of the characters which is what I would prefer i.e., treat a space like any other character.

It's really driving me crazy on my website where I want to have users format precise code. Let me know if my explanation isn't clear and I'll try to explain it better.
posted by GregX3 to Computers & Internet (5 answers total)
 
Best answer: I think you want to turn wrapping off on the web page, like this
The first textarea on that page is like metafilter, it wraps. The s econd one has wrap="off" which makes it not wrap, and your kkkkk example should work OK.

When a textarea is in wrap mode, it's *correct* to treat a space differently than other characters, since whitespace is what's used to determine where to wrap.
posted by RustyBrooks at 10:46 AM on July 27, 2007


How would you have it work? Once the text is long enough to wrap, Firefox is wrapping at the first available space before the textarea text width.

Do you want no linebreaks, except for explicit returns?
posted by bshort at 10:47 AM on July 27, 2007


What RustyBrooks said. The default behavior is wrap="on", which makes sense for most text-entry applications, but you can toggle it in your code, e.g.

<textarea wrap="off" rows=20 cols=80></textarea>
posted by cortex at 10:49 AM on July 27, 2007


Response by poster: You guys are right, wrap="off" works perfectly. Thanks for the help.

BTW, searching for that, here's a page that lets you test each setting to see how the textareas work.
posted by GregX3 at 11:00 AM on July 27, 2007


Weird, I'd never heard of "soft" or "hard". "soft" looks to me like "virtual" which I've used before: it wraps in the browser but is sent to the server as one string. I have a feeling that some of the special arguments to wrap might be browser specific or old/deprecated. wrap="off" should work universally though, I would think.
posted by RustyBrooks at 11:10 AM on July 27, 2007


« Older What is this Science fiction story?   |   Why would a bodybuilder use Tamoxifen? Newer »
This thread is closed to new comments.