HTML <fieldset> Tag
- Previous Page <embed>
- Next Page <figcaption>
Definition und Verwendung
<fieldset>
Der Tag "legend" wird verwendet, um Elemente in einem Formular zu gruppieren.
<fieldset>
Der Tag "legend" zeichnet einen Rahmen um das betreffende Element.
<legend>
Der Tag "fieldset" definiert den Titel des Elements.
Weitere Informationen siehe:
HTML DOM Referenzhandbuch:Fieldset对象
实例
例子1
在表单中对相关元素进行分组:
<form action="/action_page.php"> <fieldset> <legend>个人信息:</legend> <label for="fname">名字:</label> <input type="text" id="fname" name="fname"><br><br> <label for="lname">姓氏:</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>
例子2
使用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">名字:</label> <input type="text" id="fname" name="fname"><br><br> <label for="lname">姓氏:</label> <input type="text" id="lname" name="lname"><br><br> <label for="email">电邮:</label> <input type="email" id="email" name="email"><br><br> <label for="birthday">生日:</label> <input type="date" id="birthday" name="birthday"><br><br> <input type="submit" value="提交"> </fieldset> </form> </body> </html>
提示和注释
提示:<legend>标签用于为<fieldset>元素定义标题。
全局属性
<fieldset>
标签还支持 HTML中的全局属性.
事件属性
<fieldset>
标签还支持 HTML中的事件属性.
Default CSS Settings
Most browsers will display the following default values <fieldset>
Element:
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); {}
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Previous Page <embed>
- Next Page <figcaption>