Definition
The cols attribute specifies the maximum number of characters per line in the <textarea> element.
Applicable Elements
The cols Attribute can be used with the following elements:
HTML <textarea> cols Attribute
The <textarea> element is a multi-line field used in HTML Forms enabling the user input data.
The cols attribute specifies the maximum number of characters per line in the <textarea> element.
Syntax
<textarea cols="60"></textarea>Usage
- The
colsattribute represents the width of the<textarea>element in characters. - If not set, the width of the
<textarea>element is 20 characters.
Values
Values can include:
- A positive integer greater than zero.
Examples
A file picker control that allows both png and jpeg uploads by defining both the media_type and `file_extension’:
<label for="message">Leave a message</label>
<textarea id="message" name="message" rows="6" cols="60"></textarea>Specification
The cols attribute HTML specification for the <textarea> element is as follows:
Browser Support
The cols attribute has the following browser support:
Desktop
| Chrome | Edge | Firefox | IE | Opera | Safari | |
|---|---|---|---|---|---|---|
cols | Yes | Yes | Yes | Yes | Yes | Yes |
Mobile
| Android Webview | Chrome Android | Firefox Android | Opera Android | iOS Safari | Samsung Internet | |
|---|---|---|---|---|---|---|
cols | Yes | Yes | Yes | Yes | Yes | Yes |
