54 of 133 menu

The legend tag

The legend tag specifies a caption above a grouping of HTML form fields made using the fieldset tag.

If you assign any CSS styles for positioning to the legend tag (float, position and etc.), then its content will leave the frame and be in the right place (there will no longer be a gap in the frame).

Example

Let's split the form into two logical blocks using two tags fieldset, and make the captions for the blocks using the tag legend:

<form> <fieldset> <legend>Buyer details</legend> <input type="text"> </fieldset> <fieldset> <legend>Seller details</legend> <input type="text"> </fieldset> </form>

:

See also

  • tag label,
    which specifies the label of the form fields
byenru