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.)
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.
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.
You can resize a textarea by clicking on the bottom right corner of the textarea and dragging the mouse.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With