Open In App

What is the use of cols Attribute in <textarea> Tags ?

Last Updated : 26 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The “cols” attribute in <textarea> Tags are used to specify the visible width of the “textarea” element in terms of columns. It determines the initial width of the textarea box, indicating the number of characters that can be displayed horizontally within the textarea.

Syntax

<textarea cols="number_of_columns"></textarea>
  • number_of_columns is the approximate number of columns or characters to be displayed horizontally within the “textarea”.
Key Point Description
Visual Width The “cols” attribute determines the visible width of the “textarea” element in terms of the number of columns or characters it can display horizontally.
Default Width If the “cols” attribute is omitted, the browser typically renders the “textarea” with a default width suitable for displaying a moderate amount of text.
User Interaction Users can resize the textarea horizontally in most modern browsers, overriding the initial width set by the “cols” attribute.

Features:

  • Width Calculation: The value of the “cols” attribute represents an approximate width in terms of the number of characters that can be displayed horizontally within the textarea.
  • User Interaction: Users can resize the textarea horizontally to adjust its width based on their preferences or the amount of text they need to input.
  • Responsive Design: While the “cols” attribute sets the initial width of the textarea, developers can use CSS to further customize the appearance and responsiveness of textarea elements.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads