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

HTML 参考手册

HTML 元素(功能排序) HTML 浏览器支持 HTML 属性 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 <fieldset> 标签


实例

组合表单中的相关元素:

<form action="/action_page.php">
 <fieldset>
       <legend>个人资料:</legend>
   <label for="fname">First     name:</label>
   <input type="text" id="fname" name="fname"><br><br>
       <label for="lname">Last name:</label>
   <input     type="text" id="lname" name="lname"><br><br>
   <label     for="email">Email:</label>
   <input type="email"     id="email" name="email"><br><br>
   <label     for="birthday">Birthday:</label>
   <input type="date"     id="birthday" name="birthday"><br><br>
   <input     type="submit" value="提交">
 </fieldset>
</form>
亲自试一试 »

下面有更多实例。


定义和用法

<fieldset> 标签可将表单内的相关元素分组。

<fieldset> 标签在相关元素周围绘制一个框。将表单内容的一部分打包,生成一组相关表单的字段。


提示和注释

提示: <legend> 标签<fieldset> 元素定义标题。


浏览器支持

元素          
<fieldset> Yes Yes Yes Yes Yes

属性

属性 描述
disabled disabled 规定应该禁用 fieldset。
form form_id 规定 fieldset 所属的一个或多个表单。
name text 规定 fieldset 的名称。

全局属性

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


事件属性

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


更多实例

实例

使用CSS设置<fieldset> 和<legend> 的样式:

<html>
<head>
<style>
fieldset {
  background-color: #eeeeee;
    }
    
legend {
  background-color: gray;
  color: white;
      padding: 5px 10px;
}

input {
  margin: 5px;
}
</style>
</head>
   <body>

<form action="/action_page.php">
 <fieldset>
       <legend>个人资料:</legend>
   <label for="fname">First     name:</label>
   <input type="text" id="fname" name="fname"><br><br>
       <label for="lname">Last name:</label>
   <input     type="text" id="lname" name="lname"><br><br>
   <label     for="email">Email:</label>
   <input type="email"     id="email" name="email"><br><br>
   <label     for="birthday">Birthday:</label>
   <input type="date"     id="birthday" name="birthday"><br><br>
   <input     type="submit" value="提交">
 </fieldset>
</form>

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

相关页面

HTML DOM 参考手册: Fieldset 对象


默认CSS设置

大多数浏览器将使用以下默认值显示 <fieldset> 元素:

fieldset { 
  display: block;
  margin-left: 2px;
  margin-right: 2px;
  padding-top: 0.35em;
  padding-bottom: 0.625em;
      padding-left: 0.75em;
  padding-right: 0.75em;
  border: 2px groove (internal value);
} 

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