Home > Enterprise >  What is best practice to force form elements onto their own line, <p> or <div> element?
What is best practice to force form elements onto their own line, <p> or <div> element?

Time:06-27

I'm practicing creating an HTML form and was wondering whether a p tag or div tag would be best practice to set each form element on it's own line.

This is what I have at the moment.

<div>
    <label for="firstname">Enter your first name:</label>
    <input id="firstname" type="text" placeholder="First Name">
</div>
<div>
    <label for="lastname">Enter your last name:</label>
    <input id="lastname" type="text" placeholder="Last Name">
</div>

CodePudding user response:

Instead of <div> or <p> use <li>s in an <ol> or <ul> (if you need <div> or <p>, use <div> because it's more for interactivity than a paragraph)

  • Related