Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6987823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:59:20+00:00 2026-05-27T18:59:20+00:00

I’m designing a form layout to be uesd on many pages within an online

  • 0

I’m designing a form layout to be uesd on many pages within an online system. A devout user of tables for this purpose for many years, I’m getting pretty used to using CSS + labels for this now.

One thing I’ve yet to be able to master is the way different browsers pad & position the label relative to the input field. I’ll give a code example, plus a close up image of how it renders in each browser (IE = IE9).

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
  <title>HTML template</title>
  <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />
  <link rel="stylesheet" type="text/css" href="reset.css" />
  <style>
body {
    font-family:Verdana,Arial,"Lucida Grande","Lucida Sans Unicode",sans-serif;
    font-size:13px;
    font-style:normal;
    font-weight:normal;
    letter-spacing:normal;
    margin:20px;
}
input {
    font-family:Verdana,Arial,"Lucida Grande","Lucida Sans Unicode",sans-serif;
    border:solid 1px #666;
    width:150px;
}
.fld {
}
.usr {
    border:solid 1px red;
}
p {
}
</style>
</head>
<body>
<p>
    <label class="usr" for="email">Email*</label>
    <input class="fld required email" type="text" name="email" id="email" value="Capital Letter">
</p>
</body>
</html>

OK – now I can post a pic – here is what it looks like after Ahmed Masud’s changes. He was right – the reset.css file I had (from http://html5reset.org/) didn’t have padding on the input element. However, even after applying the changes, there is still a variation in the alignment of the base of the text in the label compared to that in the input. Now Firefox is dead-level, and for IE & Chrome the label text is 1px higher.

enter image description here

If I remove the link to reset.css, things change again: Chrome becomes dead-level, IE puts the label 1px higher than the input text, Firefox 1px lower than the input text. See below:

enter image description here

I should point out that this is a very basic layout, simply to try and diagnose the problem. I’ll be making it look all better later. But first I need to know how to make all my text line up across all browsers with one CSS solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:59:21+00:00Added an answer on May 27, 2026 at 6:59 pm

    Okay css alignments are slightly a black art with CSS2 so let me tell you what’s happening:

    1) the reset.css you have probably is NOT resetting the padding of the input element which is why you are getting that off by 1/2 pixel error

    Try adding these to your style

    So one thing is to remove that padding from input:

     input { padding: 0 }
    

    You will now have to set the height of both label and input elements:

     .fld { height: 16px; }
     .usr { height: 16px; } 
    

    The other thing is that you probably want to align fields nicely one below the other. One way to achieve that is to make the label a block with float left property:

     .usr { display: block; float: left; }
    

    and the .fld a block as well:

     .fld { display: block }
    

    you would want to add some other parameters to p to make rendering something more aesthetic.

    Here is what i did to your file:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
      <title>Southrock HTML template</title>
      <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />
      <link rel="stylesheet" type="text/css" href="reset.css" />
      <style>
    
    body {
        font-family:Verdana,Arial,"Lucida Grande","Lucida Sans Unicode",sans-serif;
        font-size:13px;
        margin:20px;
    }
    
    input {
        border:solid 1px #666;
        width:150px;
        padding: 0;
        height: 16px;
    }
    
    .fld { }
    
    .usr {
        border:solid 1px red;
        height: 16px;
        display: block;
        float: left;
        margin-right: 5px;
        width: 7em;
    }
    
    p {
        clear: both;
        margin-bottom: 5px;
    } 
    
    
    
    
    </style>
    </head>
    <body>
    <p>
        <label class="usr" for="email">Email*</label>
        <input class="fld required email" type="text" name="email" id="email" value="Capital Letter">
    </p>
    <p>
        <label class="usr" for="email">First Name*</label>
        <input class="fld required email" type="text" name="fname" id="fname" value="Capital Letter">
    </p>
    </body>
    </html>
    

    This renders the same way in IE/Safari/FF/Opera

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.