HTML textarea cols 属性
htmlweb developmentfront end technology更新于 2025/3/20 6:36:17
<textarea> 元素的 cols 属性用于设置文本区域的宽度。cols 属性设置了文本区域的宽度,并且该宽度在文本区域下方可见。
以下是语法 −
<textarea cols="num">
以上,num 是文本区域的宽度。默认值为 20。
现在让我们看一个实现 <textarea> 元素 cols 属性的示例 −
示例
<!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>
输出

在上面的例子中,我们设置了两个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>
textarea 的宽度通过 cols 属性设置 −
<textare arows="6" cols="70" autofocus>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

