html tutorial - cols Attribute in HTML - html5 - html code - html form

Learn html - html tutorial - Cols attribute in html - html examples - html programs
- The cols attribute defines the visible width of a text area.
- The cols attribute specifies a column within a textarea.
Syntax for cols attribute in HTML:
<textarea cols = “number”>content </textarea>
Applies To:
Elements | Attribute |
---|---|
<textarea> | cols |
Attribute Values:
Value | Description |
---|---|
number | Specifies the width of the text area. Default value is 20. |
Sample Coding for cols Attribute in HTML:
Tryit<!DOCTYPE html>
<html>
<body>
<head>
<title>Wikitechy HTML cols attribute</title>
</head>
<textarea rows="5" cols="80">
Wikitechy is an enhanced tutorials zone providing the best learning curve.
Sample code is provided for each and every topic to improve the user's knowledge.
</textarea>
</body>
</html>
Code Explanation for cols Attribute in HTML:

- <textarea> tag used to define a multi-line text input control.
- row attribute is used to set the number of lines as “5” in a text area.
- cols attribute is used to set the width as “80” for the textarea.
Output fo cols Attribute in HTML:

- In this output, the content Wikitechy is an enhanced tutorials... had been displayed with a specified width in a text area.
Browser Support for cols Attribute in HTML:
![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|
Yes | Yes | Yes | Yes | Yes |
Tips and Notes
- The textarea size can also be determined by the CSS height and width properties.