CSS, web page formatting

Hello experts!

Please have a look at this code:


HTML

<form method="post" action="">
    <fieldset>
        <ol>
            <li class="email">
                <label for="email" >Email:</label>
                <input type="text" align="left"  id="email" name="email" title="Email address"/>
           
            </li>


CSS

fieldset {
    margin: 1em 0;
    padding: 1em;
    border: 1px solid #CCC;
}


   
    fieldset label {
        float:left;
   
        display: block;
      }


   
    fieldset input[type="text"], input[type="password"] {
        border: 1px solid #ccc;
        padding: 2px;
        font-size: 1.2em;
        color: #444;
        width: 300px;
        float:left;
    }

What I want to achieve is to position my label and input field in one row, next to each other, nicely positioned with proper horizontal distances.

How can I do it?

Thank you!

panJames
panJamesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris StanyonWebDevCommented:
Try adding a width to the fieldset label. Also, because you are floating both of your elements (label and input), you'll need to clear them, so the following element sits below. Add a clear:both rule to the LIs


fieldset label {
   float:left;
   display: block;
   width:150px; //how wide do you want your labels
}

fieldset li {
   clear:both;
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.