How do I disable the resizable property of a textarea?
Set your textarea to be non-adjustable by setting the CSS resize property to none. Now, your textarea will lack a resize handle, thus barring any size alterations.
Step-by-step guide to tweaking and alternatives
Set controls on resize limits
You may want to put up boundaries using good old CSS properties like max-width, max-height, min-width, and min-height to restrain the textarea from going beyond the designated size parameters:
Empower direction-specific resizing
When resizing along both axes isn't really your thing, allow adjustments just along a single direction—vertical or horizontal:
Precise targeting with classes and IDs
Use a class or ID to apply the resize: none; rule. This allows you to selectively regulate which textareas aren't allowed the resizing feature:
Overflow matters
Notice that the resize property works if overflow ain't visible. Remember this while styling your textarea:
Check your browser compatibility
The CSS resize might have compatibility issues with older browsers. So, check out Can I use... to stay sure.
Disabling resizing—only if you must!
Think twice, thrice, or as many times as you need before you disable resizing. Your users might need resizing, so, tread carefully!
Additional tips and tricks to supercharge your textareas
Spark help text with placeholder attribute!
The placeholder attribute provides textual cues for users about what to input. User friendly, eh?
Textarea row count for visible height control
Use the rows attribute to tweak the visible height:
Inline styling for quick tests or dirty fixes
Do you want a quick fix or maybe want to test something rapidly? Go inline!
User customization overrides are important
Users might want to override styles for customization. Let !important take charge and ensure that certain styles stick around:
While at it, remember to respect user preferences and need for flexibility!
Was this article helpful?