Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Alignment of buttons (HTML, CSS)

Posted on 2011-03-11
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 43

Accepted Solution

David S. earned 1000 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. (http://www.positioniseverything.net/explorer/doubled-margin.html)

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

730 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