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>.
Syntax:
<textarea cols = "value">Text content...</textarea>
Example:
<!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> |
chevron_right
filter_none
Output:

Supported Browsers: The browser supported by cols attribute are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Apple Safari
Recommended Posts:
- HTML | <textarea> cols Attribute
- HTML | <frameset> cols Attribute
- HTML | DOM Textarea cols Property
- How to hide text-overflown as ellipsis using dynamic bootstrap cols ?
- HTML | <html> xmlns Attribute
- HTML | scoped Attribute
- HTML | <th> valign Attribute
- HTML | <col> align Attribute
- HTML | poster Attribute
- HTML | Class Attribute
- HTML | style attribute
- HTML | <area> target Attribute
- HTML | oninvalid Event Attribute
- HTML | <select> autocomplete Attribute
- HTML & CSS | Tabindex attribute & Navigation bars
- HTML | <table> bgcolor Attribute
- HTML | onsubmit Event Attribute
- HTML | onunload Event Attribute
- HTML | srcdoc Attribute
- HTML | Marquee truespeed attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


