HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Textarea Object : Change the width of a text area
The cols property sets or returns the value of the cols attribute of a text area.
The cols attribute specifies the visible width of a text area, in characters.
Property | |||||
---|---|---|---|---|---|
cols | Yes | Yes | Yes | Yes | Yes |
Return the cols property:
Set the cols property:
Value | Description |
---|---|
number | Specifies the width of the text area (in average character width). Default is 20 |
Return Value: | A Number, representing the width of the text area, in characters |
---|
Get the width of the text area, in characters:
var x = document.getElementById("myTextarea").cols;
Change the width of a text area using the style.width property:
document.getElementById("myTextarea").style.width = "500px";
Change the width and height of a text area using the cols and rows properties:
document.getElementById("myTextarea").cols = "100";
document.getElementById("myTextarea").rows = "10";
Change the width and height of a text area using the style.width and style.height properties:
document.getElementById("myTextarea").style.width = "500px";
document.getElementById("myTextarea").style.height = "100px";
HTML reference: HTML <textarea> cols attribute
❮ Textarea Object