Turn off resize textarea in Chrome & Safari


Chrome Textarea

Chrome Textarea

There is a new feature in both Safari and Chrome that allows a textarea to be resized by the user. In both browsers the feature is seen by a little icon that is in the bottom right corner of the textarea. This feature gives the user the ability to choose how much space they need for whatever it is they are writing.

For some websites this new feature may not be desired as resizing the textarea could break the layout of the website. I can think of a few ways to prevent the layout from breaking.

  1. Design the page with a liquid layout
  2. Turn off the users ability to resize the textarea
  3. Give the textarea a max size

Redesigning the site with a liquid layout can be a lot of work and may not be optimal for the look & feel for the site. Many designers prefer to lock the site at a certain width to guarantee that everyone will see a website that looks exactly the same.

It is very easy to turn off the users ability to resize the textarea. Turning this feature off may be necessary due to the design of certain sites or to make it harder for the user to write a 100 page document in a small comment box. The following CSS can be used to remove the users ability to resize the textarea:

textarea{resize: none}

Place that code in your css file to remove the users ability to resize any textarea on the site. You could also remove it from 1 textarea on a page with inline css.

<textarea name="myTextarea" rows="3" cols="30" style="resize: none;"></textarea>

The third option of giving the textarea a max size has a similar solution of using css. The two properties that can be used are max-width and max-height. This will give the user the ability to resize the textarea but limit them to a certain max size. The css would look something like the following.

textarea{max-width: 100px; max-height: 100px;}

Of course you may only want to use one of the above properties to allow the user to grow the height to any size but not resize the width or vice versa.

An example of a site that could use one of the above steps is whitehouse.gov. There are two screen shots below that show the before and after of the user resizing the textarea.

Browsers giving the user the ability to resize a textarea is a great feature but it creates one more item that designers and developers need to be aware of when adding a textarea to a page.

Before

Before

[caption id="attachment_173" align="alignleft" width="300" caption="After"]After[/caption]

Related Posts:

6 Responses to “Turn off resize textarea in Chrome & Safari”

  1. Igor Skomorokh
    Igor Skomorokh Says:

    Thank you very much! Very helpful info.

  2. ZAM
    ZAM Says:

    Very nice, thanks for the help…!!

  3. Danish Backer
    Danish Backer Says:

    Thanks a lot!
    It worked.

    One more help needed
    How to remove yellow highlight in chrome?

  4. XBS from Forex Service
    XBS from Forex Service Says:

    Thank you very much. Worked like a charm. Now I’ve finally fixed my registration form.

  5. Norman
    Norman Says:

    thanks a lot. what an annoying “feature”. :)

  6. Jotun
    Jotun Says:

    Thanks for the help.
    However, I had a little bit of difficulty. Using Chrome 2.0.172.37, implementing either the max-height and max-width values equal to the original dimensions of the textarea somehow only led to the textarea being resizeable in one direction (horizontally, if the max-width was the first declaration in the code or vertically if max-height came first). And when only putting in the resize: none; to the style (not maximum dimension values), the textarea was resizeable. But when adding both the resize: none; and maximum dimension values, the textarea remained fixed.

    Here’s my code:

    #note_edit_pane{
    width: 600px;
    height: 450px;

    resize: none;
    max-width: 600px;
    max-height: 450px;
    }

    ….

    After messing around a bit more with the code, it appears as if the html comment makes the next line of code be ignored. Using a css comment /* */, however, it fixes the problem. d’oh.

    On a side note, I’m writing this post in chrome in a text area, that ironically, can be resized to the extent that it breaks the page.

Leave a Reply