Can I use the <caption> tag in a form?

Can I use the <caption> inside a form? If not, why not?

Example:

 <form> <caption>description</caption> <label>name:</label> <input /> </form> 
+4
source share
3 answers

Did you try it first?

The answer is no. (Well, you can, but that breaks the standards).

The <caption> element is used to designate a table, not a form.

Alternative solution:

If you really want to use signature forms, just add a valid element to it, which may be in CSS style, for example:

 <form> <div class="caption">This is my form caption</div> <input .../> </form> 

Another approach , which would probably be more semantically correct, would be to use <fieldset> to group your form:

 <fieldset> <legend>This is my form caption</legend> <form> <input .../> </form> </fieldset> 
+14
source

Perhaps you are looking for <legend> ?

+3
source

No, you cannot use it in a form. But you can wrap your form in a table.

 <table> <caption> .. </caption> <tr><td> <form> ... </form> </td></tr> </table> 
0
source

Source: https://habr.com/ru/post/1339615/


All Articles