Alignment of buttons (HTML, CSS)

Posted on 2011-03-11
Last Modified: 2012-05-11
Hello all,

Please refer to this web address:

The page is fine in Firefox, but not in IE.  I'm using version 9 of IE, however it doesnt seem to change between IE versions.

As you can see, I have two buttons underneath the text box.  I want them both centered with a 5px gap inbetween.

I just cant for the life of me, get the image buttons to display in the center side by side.

If I reduce the width of the <li> tag to the total with of the two images + 5px margin, the explore button just falls below in IE.

Does IE add extra margin to image buttons or something?

Thanks for any assistance,

Question by:stellaartois
  • 4
  • 2
LVL 20

Expert Comment

by:Mark Brady
ID: 35107516
It would help it you could post your html and your CSS. But just looking at it (looks perfect with google chrome) I would put a div around both buttons and make the div the same width as the white box above it. Make it "position:relative; but don't float it. Then create a packing div inside that one (empty of content) so it fills the gaps up to the left of the first button. Float this div left. Create a 5px width div to make the gap and float it left then finish with the 2nd button also floated left. With IE, anything small like 5px in height or width you should also give it a font-size:0px and line-height:0px; because Explorer likes to widen these small divs due to it's minimum font size. See if these suggestions help
LVL 17

Expert Comment

ID: 35115550
Hmmm, asking for html and css when you clearly still had access to the linked page!! I probably would've been able to solve the issue with that, but since the link leads to a 404, I guess it's been resolved?

Let's do some deductive reasoning. You mentioned 'Does IE add extra margin to image buttons' and Elvin mentions 'Make it "position:relative; but don't float it'. So I'm going to guess you were using float. IE has a double-margin bug on floated elements, which could account for your issue. Apply 'zoom: 1;' to the floated elements to force 'hasLayout' and that bug will be taken care of. Of course, I am just shooting in the dark here :)
LVL 20

Expert Comment

by:Mark Brady
ID: 35124583
Viewing the source of the HTML doesn't show linked CSS so that's why I suggested posting it.
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

LVL 42

Accepted Solution

David S. earned 250 total points
ID: 35124644
> IE has a double-margin bug on floated elements, which could account for your issue.
> Apply 'zoom: 1;' to the floated elements to force 'hasLayout' and that bug will be taken care of.

Martin, the fix for that bug is giving "display:inline" to the floated elements. (

Also floated elements automatically get "hasLayout".
LVL 17

Expert Comment

ID: 35127267
@Kravimer Damn, I'm getting sloppy, you're so right!

@elvin66 Use firebug/ie developer bar/Safari with dev enabled/Chrome to inspect the page, that'll give you all the CSS info you need... Use any modern browser (perhaps even IE) to save the entire page, it'll include all CSS. A working live example page is so much easier to work with...
LVL 20

Expert Comment

by:Mark Brady
ID: 35132151
Thanks mreuring
LVL 20

Expert Comment

by:Mark Brady
ID: 35132166
Perhaps hearing a comment from the author would be nice?

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Paper tearing animation 6 43
Css issue on scroll 1 18
How do i set sidebar width to 45% of screen width 1 12
Datepicker in PHP 9 14
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now