Disable textarea resizing for Safari and ChromeDisable textarea resizing for Safari and Chrome

Posted July 4th, 2009 in HTML and CSS

The webkit based browsers Safari and Google Chrome allow the HTML textarea to be resized by default with a grab handle in the bottom right corner. There may be times when you want to disable this function so a textarea cannot be resized.

Screenshot example of resize grip

The following screenshot shows the resize grip; I've highlighted it with a red circle.

resizeable textarea in webkit based browsers

The user can make the textarea larger but cannot size it back down below the original size.

CSS to disable resizing

The CSS to disable resizing for all textareas looks like this:

textarea {
    resize: none;
}

You could instead just assign it to a single textarea by name (where the textarea HTML is <textarea name="foo">):

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

Or by id (where the textarea HTML is <textarea id="foo">):

#foo {
    resize: none;
}

Validation errors

The above is only supported by the webkit browsers. If you run it through a CSS validator (such as the W3C CSS validator) you'll get a warning like this:

Property resize doesn't exist in CSS level 2.1 but exists in [css3] : none

Related posts:

Share or Bookmark

Share or Bookmark this page using the following services. You will need to have an account with the selected service in order to post links or bookmark this page.

Subscribe or Follow

Subscribe via RSS or email, or follow me on Facebook or Twitter below. The RSS icon takes you through to Feedburner where you can select the service or application to use.

Comments

blog comments powered by Disqus