SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2012
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Should I have to put input tag inside p tag?

    Should I have to put input tag inside p tag?
    or it's ok if I don't do that?
    Code:
                <form action="">
                 <input type="text" placeholder="Name" name="u-name">
                 <input type="email" placeholder="E-mail address" name="u-email">
                 <input type="submit" value="Subscribe">
                </form>
    or
    Code:
                <form action="">
                 <p><input type="text" placeholder="Name" name="u-name"></p>
                 <p><input type="email" placeholder="E-mail address" name="u-email"></p>
                <p><input type="submit" value="Subscribe"></p>
                </form>
    Thank you

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,177
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    In HTML4, you were encouraged to wrap form elements in some kind of block level element, like a P or a DIV, but thankfully in HTML5 that seems to have been dropped, so if you are using the latest doctype, then there won't be a validation problem on that score.

    Even if using HTML4, there won't be a problem with leaving out the Ps. Just a validation message.

    Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>Test</title>
    </head>
    <body>
    
    <form action="something.php">
        <input type="text" placeholder="Name" name="u-name">
        <input type="email" placeholder="E-mail address" name="u-email">
        <input type="submit" value="Subscribe">
    </form>
    
    </body>
    </html>

  3. #3
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    Typically the FIELDSET and LEGEND would go after the FORM start tag. That is one reason as to why it was recommended you wrap the thematically related controls and labels.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •