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

  • Home
  • SEARCH
  • 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 79795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:12:06+00:00 2026-05-10T21:12:06+00:00

This is one of the minor CSS problems that plague me constantly. How do

  • 0

This is one of the minor CSS problems that plague me constantly.

How do folks around Stack Overflow vertically align checkboxes and their labels consistently cross-browser?

Whenever I align them correctly in Safari (usually using vertical-align: baseline on the input), they’re completely off in Firefox and IE.

Fix it in Firefox, and Safari and IE are inevitably messed up. I waste time on this every time I code a form.

Here’s the standard code that I work with:

<form>     <div>         <label><input type='checkbox' /> Label text</label>     </div> </form>

I usually use Eric Meyer’s reset, so form elements are relatively clean of overrides. Looking forward to any tips or tricks that you have to offer!

  • 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. 2026-05-10T21:12:07+00:00Added an answer on May 10, 2026 at 9:12 pm

    Warning! This answer is too old and doesn’t work on modern browsers.

    I’m not the poster of this answer, but at the time of writing this, this is the most voted answer by far in both positive and negative votes (+1035 -17), and it’s still marked as accepted answer (probably because the original poster of the question is the one who wrote this answer).

    As already noted many times in the comments, this answer does not work on most browsers anymore (and seems to be failing to do that since 2013).


    After over an hour of tweaking, testing, and trying different styles of markup, I think I may have a decent solution. The requirements for this particular project were:

    1. Inputs must be on their own line.
    2. Checkbox inputs need to align vertically with the label text similarly (if not identically) across all browsers.
    3. If the label text wraps, it needs to be indented (so no wrapping down underneath the checkbox).

    Before I get into any explanation, I’ll just give you the code:

    label {   display: block;   padding-left: 15px;   text-indent: -15px; } input {   width: 13px;   height: 13px;   padding: 0;   margin:0;   vertical-align: bottom;   position: relative;   top: -1px;   *overflow: hidden; }
    <form>   <div>     <label><input type='checkbox' /> Label text</label>   </div> </form>

    Here is the working example in JSFiddle.

    This code assumes that you’re using a reset like Eric Meyer’s that doesn’t override form input margins and padding (hence putting margin and padding resets in the input CSS). Obviously in a live environment you’ll probably be nesting/overriding stuff to support other input elements, but I wanted to keep things simple.

    Things to note:

    • The *overflow declaration is an inline IE hack (the star-property hack). Both IE 6 and 7 will notice it, but Safari and Firefox will properly ignore it. I think it might be valid CSS, but you’re still better off with conditional comments; just used it for simplicity.
    • As best I can tell, the only vertical-align statement that was consistent across browsers was vertical-align: bottom. Setting this and then relatively positioning upwards behaved almost identically in Safari, Firefox and IE with only a pixel or two of discrepancy.
    • The major problem in working with alignment is that IE sticks a bunch of mysterious space around input elements. It isn’t padding or margin, and it’s damned persistent. Setting a width and height on the checkbox and then overflow: hidden for some reason cuts off the extra space and allows IE’s positioning to act very similarly to Safari and Firefox.
    • Depending on your text sizing, you’ll no doubt need to adjust the relative positioning, width, height, and so forth to get things looking right.

    I haven’t tried this specific technique on any projects other than the one I was working on this morning, so definitely pipe up if you find something that works more consistently.


    Warning! This answer is too old and doesn’t work on modern browsers.

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

Sidebar

Ask A Question

Stats

  • Questions 79k
  • Answers 79k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer For frequent uploads of small files, the fastest way would… May 11, 2026 at 4:01 pm
  • Editorial Team
    Editorial Team added an answer Symbolic equation solving is a complex problem and there is… May 11, 2026 at 4:01 pm
  • Editorial Team
    Editorial Team added an answer Have you tried having the ID be TEST.html? My guess… May 11, 2026 at 4:01 pm

Related Questions

I'm using an UpdatePanel and want to put a CompareValidator on two text boxes,
Hopefully a picture is worth a thousand lines of code because I don't want
I need to write a function that takes 4 bytes as input, performs a
We have an application that generates simulated data for one of our services for

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.