Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML | cols Attribute

  • Difficulty Level : Basic
  • Last Updated : 06 Dec, 2021

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>.

<textarea cols = "value">Text content...</textarea>

Attribute Values: It has a default value which is 20. It contains a numeric value which represents the width of the textarea  element. 

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.



<!DOCTYPE html>
    <title>HTML cols Attribute</title>
        h2 {
            text-align: center;
        <h1 style="color: green;">
            HTML cols Attribute
        <!-- 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.



Supported Browsers: The browser supported by cols attribute are listed below: 

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Apple Safari


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!