Customize Textarea Resizing with CS

Webkit-based web browsers like Safari and Chrome have led web innovation the past few years.  Whether its implementing new JavaScript APIs, providing more CSS capabilities than other browsers, or simply providing blazing-fast page rendering, WebKit has been head and shoulders above other browsers in page control and CSS features.  One of those subtle features is the ability to control textarea resizing.  FireFox will provide this same capability in Firefox 4.  Let me show how to control textarea resizing with CSS.

The CSS

Textarea resize control is available via the CSS3 resize property:

copytextarea { resize:both; } /* none|horizontal|vertical|both */
textarea.vert { resize:vertical; }
textarea.noResize { resize:none; }

Allowable values self-explanatory:  none (disables textarea resizing), both, vertical andhorizontal.  The default in Firefox, Safari, and Chrome is both.

If you want to constrain the width and height of the textarea element, that’s not a problem:  these browsers also respect max-height, max-width, min-height, and min-width CSS properties to provide resizing within certain proportions:

copy#confinedSpace textarea { resize:vertical; max-height:300px; min-height:200px; }
#confinedSpace textarea.horiz { resize:horizontal; max-width:400px; min-width:200px; }

Textarea resizing is hugely helpful when you’re looking to post a long message.  Of course sometimes you may want to disable textarea resizing to accommodate a design, and that’s fine too.  As a general rule, however, you should allow resizing.

Leave a comment