Tutorialspoint

1 Answer
Arjun Thakur

The cols attribute of the <textarea> element is used to set the width of the textarea. The cols set it and the width is visible under the textarea itself.

Following is the syntax−

<textarea cols="num">

Above, num is the width of the textarea. The default value is 20.

Let us now see an example to implement the cols attribute of the <textarea> element−

Example

 Live Demo

<!DOCTYPE html>
<html>
<body>
<h2>Interview Questions</h2>
<p>Why do you want go for the Editor Job Profile? (100 words)</p>
   <textarea rows="6" cols="70">
      Write the answer in 100 words only...
   </textarea>
   <p>What are your weaknesses? (50 words)</p>
   <textarea rows="4" cols="70">
      Write the answer in 50 words only...
   </textarea>
</body>
</html>

Output

In the above example, we have set two textarea−

<textarea rows="6" cols="70">
Write the answer in 100 words only...
</textarea>
<p>What are your weaknesses? (50 words)</p>
<textarea rows="4" cols="70">
Write the answer in 50 words only...
</textarea>

The width of the textarea is set with the cols attribute−

<textare arows="6" cols="70" autofocus>

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.