How do I disable the resizable property of a textarea?
The following CSS rule disables resizing behavior for textarea
elements:
textarea {
resize: none;
}
To disable it for some (but not all) textarea
s, there are a couple of options.
You can use class
attribute in your tag(<textarea class="textarea1">
):
.textarea1 {
resize: none;
}
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
attribute (i.e., <textarea id="foo"></textarea>
):
#foo {
resize: none;
}
The W3C page lists possible values for resizing restrictions: none, both, horizontal, vertical, and inherit:
textarea {
resize: vertical; /* user can resize vertically, but width is fixed */
}
Review a decent compatibility page to see what browsers currently support this feature. As Jon Hulka has commented, the dimensions can be further restrained in CSS using max-width, max-height, min-width, and min-height.
Super important to know:
This property does nothing unless the overflow property is something other than visible, which is the default for most elements. So generally to use this, you'll have to set something like overflow: scroll;
Quote by Sara Cope,
http://css-tricks.com/almanac/properties/r/resize/
How to disable textarea resizing?
You can use css
disable all
textarea { resize: none; }
only vertical resize
textarea { resize: vertical; }
only horizontal resize
textarea { resize: horizontal; }
disable vertical and horizontal with limit
textarea { resize: horizontal; max-width: 400px; min-width: 200px; }
disable horizontal and vertical with limit
textarea { resize: vertical; max-height: 300px; min-height: 200px; }
I think min-height
should be useful for you
How can I prevent the textarea from stretching beyond his parent DIV element? (google-chrome issue only)
To disable resizing completely:
textarea {
resize: none;
}
To allow only vertical resizing:
textarea {
resize: vertical;
}
To allow only horizontal resizing:
textarea {
resize: horizontal;
}
Or you can limit size:
textarea {
max-width: 100px;
max-height: 100px;
}
To limit size to parents width and/or height:
textarea {
max-width: 100%;
max-height: 100%;
}
Disable resizing of textarea with SimpleMDE
Try setting a max-width like this:
.padd_box_top1 {
max-width: 40%;
}
This will prevent the textarea from enlarging, if you want a min-width as well you can add that too, just add: min-width: 25%;
Change the amount of pixels to whatever you like.
Related Topics
CSS for a Sidebar Menu That Folds in and Out
Setting Full Height of Angular Components
When Using CSS Scale in Firefox, Element Keeps Original Position
Set The Same Value to Multiple Properties (CSS)
Class Names Concatenated or Separated by a Space
How to Create 3X3 Grid Menu in React Native Without 3Rd Party Lib
Issue Making Bootstrap3 Icon Spin
When to Consider Base64 (Data: Uri) Images
CSS Scale an Element with 100% Width
How to Get Rid of These SASS Linting Errors When Using Tailwind-CSS
Add Class to an Element in Angular 4
Max-Height and Max-Width with CSS Only
Default Web Page Width - 1024Px or 980Px
Angular: Updating Scope on Hover
iPhone Safari CSS Rotation Bug
How to Restrict Character Limit by Line or # of Characters with CSS