导航
×
   ❮   
HTML CSS JavaScript PHP Go Sass W3C ECMS

HTML 参考手册

HTML 元素(功能排序) HTML 浏览器支持 HTML 属性
HTML 属性 accept 属性 accept-charset 属性 accesskey 属性 action 属性 alt 属性 async 属性 autocomplete 属性 autofocus 属性 autoplay 属性 charset 属性 checked 属性 cite 属性 class 属性 cols 属性 colspan 属性 content 属性 contenteditable 属性 controls 属性 coords 属性 data 属性 data-* 属性 datetime 属性 defer 属性 dir 属性 dirname 属性 disabled 属性 download 属性 draggable 属性 enctype 属性 for 属性 form 属性 formaction 属性 headers 属性 height 属性 hidden 属性 high 属性 href 属性 hreflang 属性 http-equiv 属性 id 属性 ismap 属性 kind 属性 label 属性 lang 属性 list 属性 loop 属性 low 属性 max 属性 maxlength 属性 media 属性 method 属性 min 属性 multiple 属性 muted 属性 name 属性 novalidate 属性 onabort 属性 onafterprint 属性 onbeforeprint 属性 onbeforeunload 属性 onblur 属性 oncanplay 属性 oncanplaythrough 属性 onchange 属性 onclick 属性 oncontextmenu 属性 oncopy 属性 oncuechange 属性 oncut 属性 ondblclick 属性 ondrag 属性 ondragend 属性 ondragenter 属性 ondragleave 属性 ondragover 属性 ondragstart 属性 ondrop 属性 ondurationchange 属性 onemptied 属性 onended 属性 onerror 属性 onfocus 属性 onhashchange 属性 oninput 属性 oninvalid 属性 onkeydown 属性 onkeypress 属性 onkeyup 属性 onload 属性 onloadeddata 属性 onloadedmetadata 属性 onloadstart 属性 onmousedown 属性 onmousemove 属性 onmouseout 属性 onmouseover 属性 onmouseup 属性 onmousewheel 属性 onoffline 属性 ononline 属性 onpageshow 属性 onpaste 属性 onpause 属性 onplay 属性 onplaying 属性 onprogress 属性 onratechange 属性 onreset 属性 onresize 属性 onscroll 属性 onsearch 属性 onseeked 属性 onseeking 属性 onselect 属性 onstalled 属性 onsubmit 属性 onsuspend 属性 ontimeupdate 属性 ontoggle 属性 onunload 属性 onvolumechange 属性 onwaiting 属性 onwheel 属性 open 属性 optimum 属性 pattern 属性 placeholder 属性 poster 属性 preload 属性 readonly 属性 rel 属性 required 属性 reversed 属性 rows 属性 rowspan 属性 sandbox 属性 scope 属性 selected 属性 shape 属性 size 属性 sizes 属性 span 属性 spellcheck 属性 src 属性 srcdoc 属性 srclang 属性 srcset 属性 start 属性 step 属性 style 属性 tabindex 属性 target 属性 title 属性 translate 属性 usemap 属性 value 属性 width 属性 wrap 属性
HTML 全局属性 HTML 事件 HTML 颜色 HTML 画布 HTML 音频/视频 HTML 字符集 HTML 文档类型 HTML URL 编码 HTML 语言代码 HTML 国家代码 HTTP 状态消息 HTTP 请求方法 PX-EM 转换 键盘快捷键

HTML 标签

<!--> <!DOCTYPE> <a> <abbr> <acronym> <address> <applet> <area> <article> <aside> <audio> <b> <base> <basefont> <bdi> <bdo> <big> <blockquote> <body> <br> <button> <canvas> <caption> <center> <cite> <code> <col> <colgroup> <data> <datalist> <dd> <del> <details> <dfn> <dialog> <dir> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <font> <footer> <form> <frame> <frameset> <h1> - <h6> <head> <header> <hr> <html> <i> <iframe> <img> <input> <ins> <kbd> <label> <legend> <li> <link> <main> <map> <mark> <meta> <meter> <nav> <noframes> <noscript> <object> <ol> <optgroup> <option> <output> <p> <param> <picture> <pre> <progress> <q> <rp> <rt> <ruby> <s> <samp> <script> <section> <select> <small> <source> <span> <strike> <strong> <style> <sub> <summary> <sup> <svg> <table> <tbody> <td> <template> <textarea> <tfoot> <th> <thead> <time> <title> <tr> <track> <tt> <u> <ul> <var> <video> <wbr>

HTML <textarea> 标签


实例

一个 HTML 文本区域:

<label for="w3review">FreeW3C 的评论:</label>

<textarea id="w3review" name="w3review" rows="4" cols="50">
在www.freew3c.com,您将学习如何制作网站。 他们提供所有网络开发技术的免费教程。
</textarea>
亲自试一试 »

下面有更多实例。


定义和用法

<textarea> 标记定义了一个多行文本输入控件。

<textarea> 元素通常用于表单中,用于收集用户输入,如评论或评论。

文本区域可以容纳无限数量的字符,并且文本以固定宽度字体呈现 (usually Courier).

可以通过 <cols><rows> 属性来规定 textarea 的尺寸,不过更好的办法是使用 CSS 的 height 和 width 属性。

提交表单后,需要 name 属性来引用表单数据(如果省略 name 属性,则不会提交文本区域中的数据)。

将文本区域与标签关联需要 id 属性。

提示: 始终添加< <label> 标签以获得最佳可访问性实践!


浏览器支持

元素          
<textarea> Yes Yes Yes Yes Yes

属性

属性 描述
autofocus autofocus 规定在页面加载后文本区域自动获得焦点。
cols number 规定文本区内的可见宽度。
dirname textareaname.dir 指定将提交 textarea 的文本方向
disabled disabled 规定禁用该文本区。
form form_id 规定文本区域所属的一个或多个表单。
maxlength number 规定文本区域的最大字符数。
name text 规定文本区的名称。
placeholder text 规定描述文本区域预期值的简短提示。
readonly readonly 规定文本区为只读。
required required 规定文本区域是必填的。
rows number 规定文本区内的可见行数。
wrap hard
soft
规定当在表单中提交时,文本区域中的文本如何换行。。

全局属性

<textarea> 标签支持 HTML 中的全局属性


事件属性

<textarea> 标签支持 HTML 中的事件属性


更多实例

实例

禁用默认调整大小选项:

<html>
<head>
<style>
textarea {
  resize: none;
}
</style>
 </head>
<body>

<label for="w3review">Freew3c 的评论:</label>
  
<textarea id="w3review" name="w3review" rows="4" cols="50">
在www.freew3c.com,您将学习如何制作网站。 他们提供所有网络开发技术的免费教程。
</textarea>

</body>
</html>
亲自试一试 »

相关页面

HTML DOM 参考手册: Textarea 对象

CSS 教程: Styling Forms


默认CSS设置

None.


Copyright ©2020-2026 freew3c.com All Rights Reserved 提供的内容仅用于学习和测试,不保证内容的正确性。