Creating a Form with Legend Tag
In HTML, the <legend>
tag is used to add a caption to a <fieldset>
element. This is commonly used to provide a label for a group of related form fields.
Example:
Explanation:
In the above example, the <fieldset>
element is used to group the form fields related to contact information. The <legend>
tag is used to provide the caption “Contact Information” for this group.
Styling the Legend Tag:
By default, the <legend>
tag is displayed as a bold caption above the <fieldset>
box. You can use CSS to style the <legend>
tag to change its appearance, such as font size, color, and alignment.
Conclusion:
The <legend>
tag is a useful HTML element for creating accessible and well-structured forms. It helps to provide context and organization for related form fields, making it easier for users to understand the purpose of each input.
Source code
source code?