HTML cols attribute
cols
The purpose of the HTML cols attribute is to define the number of columns in a text area or frame set.
Supported elements
HTML cols attribute supports textarea and frameset elements. cols is a required attribute for textarea.
Syntax
<ElementName cols="value">..............</ElementName>
Where ElementName is any supported HTML element.
Type of value
Multilength for frameset and number for textarea.
Value
A relative length if used with frameset and a number to specify number of columns if used with textarea.
Default value
There is no default value.
Supported doctypes
HTML 4.01 strict, HTML 4.01 transitional, HTML 4.01 frameset when used with textarea. HTML 4.01 frameset when used with frameset.
Example of HTML cols attribute with textarea
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><!-- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> -->
<title>Example of HTML cols attribute with textarea</title>
</head>
<body>
<form action="action.php" accept="image/png,image/jpeg,image/gif">
Email id : <input type="text" name="email"/><br/>
Password : <input type="text" name="passw"/><br/>
Describe yourself : <textarea cols="10" rows="5"></textarea> <br/>
Upload your photograph: <input type="file" name="uimg" id="uimg"/><br/>
<input type="submit" value="Submit"/>
</form>
</body>
</html>
Result

View this example in a separate browser window
Example of HTML cols attribute with textarea
Example of HTML cols attribute with frameset
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example of HTML cols attribute with frameset</title>
</head>
<frameset cols="20%,*,20%">
<frame src="frame_left.htm" />
<frame src="frame_center.htm" />
<frame src="frame_right.htm" />
</frameset>
</body>
</html>
Result

View this example in a separate browser window
Example of HTML cols attribute with frameset
Previous: HTML codetype attribute
Next: HTML colspan attribute
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook