SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    prevent horiz. scroll in textarea: soft wrap very long words?

    Hi all,

    I'm doing a little personal project for fun, and it'd be great to know how to get a very long word to wrap inside a textarea. I mean, imagine typing a long string of random digits, say, without spaces in-between. What I want is for the string to go to a newline inside the textbox even though there isn't a space. I want this change to be 'virtual' or 'soft' so that the actual string itself still doesn't have spaces. My browser currently adds a horizontal scrollbar instead of breaking the line.

    Obviously, this is counter to what most people want, so I'm prepared to accept that there may not be a way to do it. But still I'd like to try if anyone can help me out!

    Thanks

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Welcome to SitePoint!

    There is no standards-compliant way to do it. The specs only allow lines to be wrapped at whitespace characters (space, tab, carriage return, line feed). IE and Opera incorrectly wrap at some other characters as well (hyphens, brackets, etc.) but that violates the specs.

    There are proprietary HTML attributes and CSS properties that can achieve what you're looking for, but only in one or two browsers.
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Member
    Join Date
    Jan 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    Welcome to SitePoint!

    There is no standards-compliant way to do it. The specs only allow lines to be wrapped at whitespace characters (space, tab, carriage return, line feed). IE and Opera incorrectly wrap at some other characters as well (hyphens, brackets, etc.) but that violates the specs.

    There are proprietary HTML attributes and CSS properties that can achieve what you're looking for, but only in one or two browsers.
    Ah well -- a minor drawback. I'd much rather be standards-compliant. I can think of a few ways to cut the Gordian knot, as it were, but I'll just work on getting my proof of concept up and running.

    Thanks for the prompt help! Much appreciated.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •