Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Feb 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Web Forms and CSS Positioning

    I am trying to create a web form without tables, just CSS something like this:

    First Name: ____________ Last Name: __________________
    Address: ________________________________________
    City: _____________________ State: ___ Zip: ______

    Is there anyway in CSS to do this without using tables?

    I am able to create a form that looks like this:

    First Name: ____________________
    Last Name: ____________________
    Address: ________________________________
    City: _________________
    State: ___
    Zip: _________

    using this CSS code:

    body
    {
    margin:0 auto;
    width:740px;
    background:#f4f4f4;
    }

    #input_form
    {
    font-family:Georgia,Arial;
    font-size:.65em;
    margin-top:60px;
    background:#ffffff;
    padding-top:20px;


    }
    form label
    {
    float:left;
    width:150px;
    text-align:right;
    margin-right:.7em;
    padding-top:.3em;



    }
    form input
    {
    font-family:Georgia,Arial;
    background:#ffffcc;
    font-size:1em;
    margin-bottom:2px;
    }


    and this HTML:

    <label for="last_name">First Name</label>
    <input type="text" name="first_name" id="first_name" size="20" maxlength="30" /><br />
    <label for="last_name">Last Name:</label>
    <input type="text" name="last_name" id="last_name" size="15" maxlength="35" /><br />
    <label for="first_name">Street Address:</label>
    <input type="text" name="first_name" id="Address" size="50" maxlength="50" /><br />

    <label for="last_name">City:</label>
    <input type="text" name="last_name" id="City" size="50" maxlength="50" /><br />
    <label for="last_name">State:</label>
    <input type="text" name="last_name" id="State" size="2" maxlength="2" /><br />
    <br />


    Many thanks for any help!

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,744
    Thanks
    22
    Thanked 1,838 Times in 1,822 Posts
    Hello jzfla,
    I'm not much on forms, I've only built one, but I can see right off that it's doing exactly what you've told it to do:
    Code:
    <label for="last_name">First Name</label>
    <input type="text" name="first_name" id="first_name" size="20" maxlength="30" /> <br />
    <label for="last_name">Last Name:</label>
    <input type="text" name="last_name" id="last_name" size="15" maxlength="35" /><br />
    That <br /> is a line break.
    What happens when you take it out?
    Maybe you need to float id="first_name" ?... not a clue really
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #3
    Regular Coder PremiumBlend's Avatar
    Join Date
    Apr 2006
    Location
    Marion, Iowa
    Posts
    201
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Here is a good link for designing forms. I learned a lot from it.

    http://www.alistapart.com/articles/p...ccessibleforms
    My Website: DumpsterDoggy

  • #4
    Regular Coder
    Join Date
    Oct 2006
    Posts
    164
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Or if you want to get ahead of everyone, you can use xforms.

    http://www.w3schools.com/xforms/default.asp

  • #5
    New Coder
    Join Date
    Feb 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a lot for the tutorials. I've been all over the web and all the form tutorials seem to use a vertical layout. I would like to create more of a data entry form using CSS instead of tables.


  •  

    Posting Permissions

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