Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Textarea cols property

Textarea cols property

Textarea Object Reference The Textarea object


Example

Modify the width of the textarea element:

document

.

getElementById

(

"

myTextarea

"

)

.

cols

=

"

100

"

;

Try it »

Definition and Usage

The cols property is used to set or return the value of the cols property.

The cols property specifies the width of the text box, in characters.

Tip: You can use the style.width Property used to set the width of the textarea element.

Tip: You can use the rows and style.height Property used to set the width and height of the textarea element.


Browser support

property
cols Yes Yes Yes Yes Yes

Syntax

Set the cols property:

textareaObject.cols = number

Return the cols property:

textareaObject.cols


Attribute values

Value Description
number

Specifies the width of the text box. Default is 20.


Technical Details

Return value: A number, representing the width of the text box, in characters.

More examples

Example

Use the style.width property to modify the width:

document

.

getElementById

(

"

myTextarea

"

)

.

style

.

width

=

"

500px

"

;

Try it »

Example

Use the cols and rows properties of the textarea element to modify the height and width:

document

.

getElementById

(

"

myTextarea

"

)

.

cols

=

"

100

"

;

document

.

getElementById

(

"

myTextarea

"

)

.

rows

=

"

10

"

;

Try it »

Example

Use the style.width and style.height properties to modify the width and height:

document

.

getElementById

(

"

myTextarea

"

)

.

style

.

width

=

"

500px

"

;

document

.

getElementById

(

"

myTextarea

"

)

.

style

.

height

=

"

100px

"

;

Try it »


Textarea Object Reference The Textarea object