HTML cols Attribute

HTMLWeb DevelopmentFront End Technology

The cols attribute in HTML is used for both <textarea> as well as <frameset> element. Since the <framset> tag is not supported in HTML5, therefore we will be working on <textarea> cols attribute.

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" autofocus>
      Write the answer in 100 words only...
   </textarea>
   <p>What are your weaknesses? (50 words)</p>
   <textarea rows="4" cols="70" autofocus>
      Write the answer in 50 words only...
   </textarea>
</body>
</html>

Output

raja
Published on 20-Jun-2019 10:24:13
Advertisements