SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: I need more help on styling a form.

  1. #1
    SitePoint Zealot
    Join Date
    Feb 2001
    Location
    Kansas City, MO
    Posts
    145
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I need more help on styling a form.

    I am trying to alter this form so that the labels/text is on the top of the inputs/textarea. I have been trying to get it to work but cannot figure it out.

    Any and all help is appreciated.

    Thanks,
    AC

  2. #2
    Barefoot on the Moon! silver trophy
    Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    3,668
    Mentioned
    21 Post(s)
    Tagged
    1 Thread(s)
    Do you have the code for the form you're working with?
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  3. #3
    The CSS Clinic is open silver trophybronze trophy
    SitePoint Award Recipient Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    37,800
    Mentioned
    99 Post(s)
    Tagged
    3 Thread(s)
    If you set the label element to display:block then the input will automatically drop down under it.

    e.g.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Untitled Document</title>
    <style type="text/css">
    form {
        margin:0;
    }
    .details label {
        display:block;
        padding:2px;
    }
    .details input {
        display:block;
        margin:0 0 10px;
    }
    </style>
    </head>
    <body>
    <form class="details" name="form1" method="post" action="">
        <fieldset>
        <legend>Personal Details</legend>
        <div>
            <label for="name">Enter Name :</label>
            <input type="text" name="name" id="name">
        </div>
        <div>
            <label for="address">Enter Address :</label>
            <input type="text" name="address" id="address">
        </div>
        </fieldset>
    </form>
    </body>
    </html>

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just as Paul said, applying display:block to the input/submit (or even better to input/text) it will push everything on its side(s) to a next row.

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
  •