The HTML cols attribute
Quick answer
The HTML cols attribute sets the visible width of the textarea in average character widths. It is used on the <textarea> element.
Overview
The cols attribute sets the visible width of a textarea. It is used on the <textarea> element.
It configures a <textarea> multi-line text field: its visible size and how line breaks are handled on submission.
Syntax
<textarea cols="40" rows="4"></textarea>
Values
| Value |
|---|
| A positive integer (default 20). |
Example
<textarea cols="30" rows="3">Resize me</textarea>
Best practices
Frequently asked questions
What does the cols attribute do?
Sets the visible width of a textarea.
How do I set the size of a textarea?
What is the difference between wrap="soft" and wrap="hard"?
It controls whether the browser's automatic wrap points become real line breaks in the submitted value:
soft (the default) submits the text unchanged, while hard inserts a line break at each wrap point and requires cols to be set.Which elements use the cols attribute?
It is an element-specific attribute, used on the <textarea> element.