We will use legend tag to define caption for fieldset, figure and details element. In html 4.01 legend tag defines caption only for fieldset element but in html5 legend tag defines caption for fieldset, figure and details element.
Following example will demonstrate use of legend tag to define caption for fieldset
<body>
<form>
<fieldset style="width:300px;">
<legend style="margin-left:70px">Personal Information</legend>
First Name: <input type="text" size="30" /><br />
Last Name: <input type="text" size="30" /><br />
Email: <input type="text" size="30" /><br />
Date of birth: <input type="text" size="10" />
</fieldset>
</form>
</body>
Anonymous User
22-Jul-2019Thanks for sharing.