<legend>...</legend>

HTML4 HTML5

Defines a caption/title for the content of a <fieldset> element. Placed as the first child of <fieldset> to provide accessibility context for grouped form fields.

Both opening and closing tags are required.

Attributes: Global attributes apply, such as class, id, and style.

Example

Code:

<fieldset style="border: 1px solid #ccc; padding: 10px; border-radius: 4px;"> <legend style="font-weight: bold; padding: 0 5px;">Personal Data</legend> <label for="imie">Name:</label> <input type="text" id="imie" placeholder="John"> </fieldset>

The browser will interpret this code as follows:

Personal Data