Last Updated : 11 Jul, 2025
The cols attribute in HTML is used to tell the browser how many average-width characters should fit on a single line i.e. the number of columns to display.
Note: This attribute is only applicable on <textarea> and <frameset>.
Syntax:
<textarea cols = "value">Text content...</textarea>
Attribute Values: It has a default value which is 20. It contains a numeric value that represents the width of the text area element.
Example: In this example, we use the cols attribute in a <textarea> to set its width to fit 25 characters per line, with a predefined height of 4 rows.
html
<!DOCTYPE html>
<html>
<head>
<title>HTML cols Attribute</title>
<style>
h1,
h2 {
text-align: center;
}
</style>
</head>
<body>
<center>
<h1 style="color: green;">
GeeksforGeeks
</h1>
<h2>
HTML cols Attribute
</h2>
<!-- Below textarea is assigned a cols value 25
That is, 25 characters will fit in a line -->
<textarea rows="4" cols="25">
A computer science portal for geeks.
</textarea>
</center>
</body>
</html>
Output:
Supported Browsers: The browser supported by cols attribute are listed below:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4