The legend tag in HTML
- 24-07-2022
- Trung Minh
- 0 Comments
The legend tag will create a caption for the fieldset group.
Use a combination of the legend tag with the fieldset tag to clearly describe the group of related sections that have been grouped with the fieldset tag.
Using
For example : Use the legend tag to provide information to the user with the content of the fields in the group that belong to the customer or the store.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <h2>Thẻ legend Trong HTML</h2> <div> <form> <fieldset> <legend>Thông tin khách hàng</legend> Tên: <input type="text"><br> Email: <input type="text"><br> Địa chỉ: <input type="text"> </fieldset> <fieldset> <legend>Thông tin cửa hàng</legend> Tên: <input type="text"><br> Địa chỉ: <input type="text"> </fieldset> </form> </div> </body> </html>
As we can see, without the legend tag to describe the fieldset group, grouping the fields will not give the user any information about the fields inside.