w3resource

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

html cols attribute with textarea

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

html cols attribute with frameset

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.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/html/attributes/html-cols-attribute.php