Is it wrong to use paragraph tags for html for input?

So far, I have mainly put labels and entries in the highlighted paragraph tag:

<p> <label for="myInput">Blah</label> <input type="text" ... /> </p> 

But this tag is for a text paragraph. Is it semantically correct to use it that way? Should a div be used?

+4
source share
2 answers

Semantically, no, this is not true. Form inputs are not paragraphs in any sense of the word.

If you're a CSS expert, try using the <ol> and <li> tags and reinstall them to see how you like, since your form fields are an ordered list of elements. See A List Apart for an article on Prettier Accessible Forms for an example of the HTML and CSS required for this format.

+6
source

It seems you almost answered your first question, since it is not a paragraph semantically, so using <p> is wrong for me.

The second question about whether to use a <div> depends on your use, but I don’t understand why not, except for the increasingly cumbersome code, although this probably will not add a lot of weight to the page.

My own tendency is for the <input /> socket in the <label> , although this, again, is semantic incorrect, since the input is not part of the label, being only its analogue.

Of course, both methods work and produce a lot of the same visual effect; I have never used an alternative converter-converter or one-to-one GUI browser, so I can’t say if it adds weirdness to disconnected users.

+1
source

All Articles