/

HTML / CSS / JavaScript Tutorial

HTML Standard attribute: cols

[this page | pdf | back links]

The HTML cols attribute indicates the visible width of a <textarea> element (in number of characters).

 

Valid attribute values (when used with <textarea> elements) include:

 

Value

Description

integer

Visible width (in characters) of text area

 

The visible height of a <textarea> element can be set using the rows attribute. The size of a <textarea> element can also be set using CSS height and width properties.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Created using HTML:<br>
<form action="http://www.nematrian.com/ExpressionEvaluator.aspx">
<textarea type="text" name="expr" rows="3" cols="25">3*5</textarea>
<br><input type="submit" value="Go to webpage to evaluate">
</form>

<br>Created using JavaScript:<br>
<span id="element"></span>

<script>
var f = document.createElement("FORM");
f.setAttribute("action","http://www.nematrian.com/ExpressionEvaluator.aspx");
var x1 = document.createElement("TEXTAREA");
x1.setAttribute("type","text");
x1.setAttribute("name","expr");
x1.setAttribute("rows","3");
x1.setAttribute("cols","25");
var txt1 = document.createTextNode("3*5");
x1.appendChild(txt1);
var br1 = document.createElement("BR");
var x2 = document.createElement("INPUT");
x2.setAttribute("type","submit"); x2.setAttribute("value","Go to webpage to evaluate");
f.appendChild(x1);
f.appendChild(br1);
f.appendChild(x2);
document.getElementById("element").appendChild(f);
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile