Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding textarea resize handle in Safari

Tags:

css

safari

webkit

I'm using textarea components in my application, and I control their height dynamically. As the user types, the height is increased whenever there is enough text. This works fine on IE, Firefox, and Safari.

However, in Safari, there is a "handle" tool in the lower right that allows user to resize the textarea by clicking and dragging. I also noticed this issue with the textarea in the stackoverflow Ask a Question page. This tool is confusing and basically gets in the way.

So, is there anyway to hide this resize handle?

(I'm not sure if "handle" is the right word, but I cannot think of a better term.)

like image 477
david.mchonechase Avatar asked Feb 25 '09 21:02

david.mchonechase


People also ask

How do I hide the resize textarea icon?

To prevent a text field from being resized, you can use the CSS resize property with its "none" value. After it you can use the height and width properties to define a fixed height and width for your <textarea> element.

How do I restrict textarea size?

You can set the size of a text area using the cols and rows attributes. To limit the number of characters entered in a textarea, use the maxlength attribute. The value if the attribute is in number. Specifies that on page load the text area should automatically get focus.

How do I resize textarea in HTML?

You can resize a textarea by clicking on the bottom right corner of the textarea and dragging the mouse.


2 Answers

You can override the resize behaviour with CSS:

textarea {    resize: none; } 

or just simply

<textarea style="resize: none;">TEXT TEXT TEXT</textarea> 

Valid properties are: both, horizontal, vertical, none

like image 145
Tamas Czinege Avatar answered Oct 21 '22 11:10

Tamas Czinege


Use the following CSS rule to disable this behavior for all TextArea elements:

textarea {     resize: none; } 

If you want to disable it for some (but not all) TextArea elements, you have a couple of options (thanks to this page).

To disable a specific TextArea with the name attribute set to foo (i.e., <TextArea name="foo"></TextArea>):

textarea[name=foo] {     resize: none; } 

Or, using an ID (i.e., <TextArea id="foo"></TextArea>):

#foo {     resize: none; } 

Note that this is only relevant for WebKit-based browsers (i.e., Safari and Chrome), which add the resize handle to TextArea controls.

like image 36
Gaurang P Avatar answered Oct 21 '22 09:10

Gaurang P