HTML cols Attribute

By Jonathan Griffin. Editor, SEO Consultant, & Developer.

· 1 min read

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 cols attribute 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

ChromeEdgeFirefoxIEOperaSafari
colsYesYesYesYesYesYes

Mobile

Android WebviewChrome AndroidFirefox AndroidOpera AndroidiOS SafariSamsung Internet
colsYesYesYesYesYesYes