Question

CSS behaving differently in IE than Firefox

Asked by: dageyra

I have coded CSS to get our template to work in Firefox, which it does.  However, when I test the page in IE, the positioning is way off.  The template is very simple, a banner with a left navigation and content area.  In order to get the content at the top of the HTML, we use div's and position the elements accordingly.  Only the banner is positioned with absolute, the menu and content are not because there is a pull out menu that does not work correctly with absolute positioning.  However, in Firefox, I am able to get the sections to line up correctly using the top element.

To see the page working in Firefox (and not working in IE), navigate to:
http://www.goshoppingaroundtheweb.com/index.php/RyanTest.html

You can see a working template (in tables, not divs and css) here: http://www.goshoppingaroundtheweb.com/
This gives you the idea of what I was trying to mimic in CSS.

If you look at the CSS, you will see that there is a div for the banner, some header text (which is empty), a wrapper for the content that contains a div for the menu and a div for the content.  The banner is absolute position, but for some reason in IE, it is way off center.  The menu is also positioned strangely in IE, though it appears the content is fine.

There is also a global wrapper that centers the page, and this may be the problem.  I center using auto margins.

Does anyone have any ideas on how I can alter the CSS to work properly in Firefox & IE or what changes I could make to an IE-only stylesheet that I can include?  Thanks in advance for any assistance.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-04-22 at 10:27:19ID24346113
Tags

CSS

,

IE

,

Firefox

,

different behavior

Topics

Cascading Style Sheets (CSS)

,

Hypertext Markup Language (HTML)

,

Internet Explorer Web Browser

Participating Experts
1
Points
500
Comments
16

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Css in firefox.
    Hello, please see this site in firefox http://www.sahilonline.org/english/index.asp it will not display properly. Even CSS is already validated http://jigsaw.w3.org/css-validator/validator?profile=css2&warning=2&uri=http://www.sahilonline.org/english/english_2.css ...
  2. CSS Margin difference between IE and Firefox
    Hey everyone I am creating a css layout for a new website. So far, I am simply laying out the divs in a 800px wide main container. I am noticing that that IE is 1 px off from Firefox on the right side. I have a bg image (830px wide, white with gradients on each side. This ...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: xSuperioRxPosted on 2009-04-22 at 12:24:34ID: 24208571

Try setting text-align: center; in the body part of your CSS file.

Just something i noticed that often helps IE.
If that doesn't work ill check some more into it.

 

by: dageyraPosted on 2009-04-22 at 12:59:03ID: 24208942

Hello xSuperioRx:

I added that to the CSS file (seo.css), but it didn't seem to make a difference.  I'll verify the setting is not getting overwritten, but do you have any other suggestions?

 

by: dageyraPosted on 2009-04-22 at 13:06:17ID: 24209019

Just to verify, I added the text-align: center to a in-page style, which should overwrite any other body elements.  I await any further assistance you can provide.

 

by: xSuperioRxPosted on 2009-04-22 at 13:41:39ID: 24209373

Hmmm takes some time to read through everything.

IE does have problems with using auto margins.

I'll submit some of the code that i've used that i'm sure works. (Using it on my page with very few changes, like background-color etc)

The code i submitted basically makes the #main div in the horizontal center of the page.

Note sure if it'd do anything but try changing your :
margin-left:auto; margin-right:auto
in your #container to:
margin : 0 auto;

Sadly you do have too many .css files on that page for me to look through them all :) So another tip would be to start out with a clean css start and then work your way slowly forward. (As im guessing you are changing from tables to divs). And keep checking regularly that all browsers work as intended.

Please keep me up to date on your process!

html, body {margin: 0;padding: 0;text-align:center;font-family: Arial, Helvetica, sans-serif;}
 
#main{text-align:left; margin:0 auto; padding:5px; width:740px; height:510px; border: solid 1px #000; position:relative; clear:both;}
                                              
1:
2:
3:

Select allOpen in new window

 

by: dageyraPosted on 2009-04-22 at 13:44:37ID: 24209404

Hello xSuperioRx:

Thanks for your suggestion, I will try it out.  Regarding the number of CSS files, it is a Joomla CMS, which adds its own CSS.  However, the only difference between the home page and my test page is the seo.css file, which is where the margin info is contained (and what handled the transition from table to div).

I will let you know how it turns out!

 

by: dageyraPosted on 2009-04-22 at 14:31:29ID: 24209894

If it helps, I removed several of the stylesheets.  I may need to add the base template back in, but right now there are only 2 (the seo.css which is the table->div conversion and swfree.css which handles the menu styling).

Does this help narrow down the problem?  With only these 2, I still get the same behavior in IE, but in Firefox the page is no longer centered.

 

by: xSuperioRxPosted on 2009-04-22 at 14:37:28ID: 24209938

I notice some errors in the code now:

margin-left : 0 auto; and margin-right: 0 auto;
should be margin:0 auto; (without -left -right)

margin:0 auto; basically means that top and bottom should be 0, and left and right should be auto;
That is of course almost identical like you had it, but who knows what IE thinks about sometimes ;)

Also you cannot comment  in the css using //
So change the following :
//position: relative;

Also a good way to check your CSS for errors is :
http://jigsaw.w3.org/css-validator/

I'll take a quick peek at your css again before going to bed :)

 

by: dageyraPosted on 2009-04-22 at 14:40:06ID: 24209963

Thanks again for your help, I missed those margin subtleties.  Because we are using opacity (which is valid CSS 3 but not 2, which the validator uses), I cannot completely rely on the CSS validator.  I will make sure there are no other errors besides the opacity however.  Thanks also for the tip on the comment, not sure how that snuck in there.

 

by: dageyraPosted on 2009-04-22 at 14:45:56ID: 24210017

I made those changes, and Firefox is fixed now, but IE has no changed at all for me.  What I can't understand is why the banner is so far off to the right (and the menu as well, but the banner is positioned absolutely).  The only div that is positioned correctly is the content, which is inside the same wrapper as the menu.

I'm trying to think of more pieces I can take out of the HTML/CSS and still be able to identify the parts correctly--any suggestions?  I've thought about creating a standalone HTML and CSS file to toy with instead of going through Joomla.

 

by: xSuperioRxPosted on 2009-04-22 at 15:00:04ID: 24210145

Hmmm i downloaded :

http://www.microsoft.com/downloads/details.aspx?familyid=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en

which is a great help for debugging pages in IE.

With it i noticed (bah im too tired) that you arent using float:left; on any containers.

First off you should assign the divs in vertical order, so put the div containing the banner (banner) prior to the one containing the body (contentwrapper).

Put position relative on the banner div.

Use float:left; on the 'content' div and also the 'menumodule' div.

The snippet i added shows what i ment by putting the div id banner and topmodules prior to the contentwrapper div.

So yeah basically its probably the float:lefts; that i said that are missing and the position:relative;
You might also want to make a clear:both; div that helps containing the floats :)

Try around with different combinations and lets hope it gets sorted :)

More information about floats:

http://webdesign.about.com/od/advancedcss/a/aa010107.htm

Best of luck! I'll swing by tomorrow and see how you are doing :)
Hopefully i'm on the right track and not rambling in my sleep ;)

<body>
<div id="container">
	<div id="banner"> <img src="/images/banner_GSATW_1.jpg" alt="Go Shopping Around the Web Banner" width="900" height="200" /> </div>
	<div id="topModules">
	<div id="contentWrapper">
		<div id="content">
			  
			<table class="contentpaneopen">
			<tr>
			<td valign="top">
			Ryan Test
			</td>
			</tr>
			</table>
 
			<span class="article_separator">&nbsp;</span>
 
			<div id="footer">
				<p>&copy; 2009 Go Shopping Around the Web - All rights Reserved</p>
				<p>Website Design by: Kathy Farrell &amp; Jeff Dingsor<br />
				</p>
			</div>
		</div>
		<div id="menuModule">
 
		<div id="wrap" class="menu" align="left">
		</div> 
		<div id="subwrap"> 
		</div>
		<!--End swMenuFree menu module-->
		</div>
	</div>
	</div>
</div>
</body>
</html>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:

Select allOpen in new window

 

by: dageyraPosted on 2009-04-23 at 13:15:20ID: 24219314

I have the developer toolbar, but I find it's CSS ability lacking.  I originally went with something like what you are suggesting, but I was unable to get the floats to work (didn't seem to make any difference, which suggests I was using them wrong).  The overall goal here is to have the actual content in HTML source as close to the top of the page as possible (some search engines only use the top so many words for indexing, including HTML markup, so sites with content deep inside the source do not do as well).  That is why I did not pursue the vertical approach.  I will see what I can do with the floats; I definitely know that putting the menu before the content will not work because so much markup is auto-generated by the CMS.

One of my inquiries is why IE behaves so differently from Firefox.  I know the two interpret tags differently, but in this case IE is way off, so my hope was to get some advice on how to get IE to behave more like Firefox (which behaves correctly and gives the desired effect with the current source layout) using CSS and not having to restructure to source.

I will keep you posted.

 

by: xSuperioRxPosted on 2009-04-23 at 13:52:57ID: 24219696

Yes IE can be way off sometimes :) If you google "css ie" you end up with loads and loads of pages that explains all the things IE interpet different. It would probably be a good idea (guessing you already have.. but if you haven't) read through some of them to get a general view what IE does wrong (or differently).

The developer toolbar isn't that great with CSS, you're right. But you can add new attributes and see what kind of changes it does. So it does help :) (not as good as firebug with firefox, which is a great asset)

Hope you get it sorted soon!

 

by: xSuperioRxPosted on 2009-04-23 at 14:11:59ID: 24219851

Think i finally figured it out :)

To get the absolute property on the banner you need to put the container it is to relative.

So changes i made that made it look good in IE: (havent tested firefox then lol)

menuModule -> float : left;
container -> position : relative;
banner -> left:0px;

Hope thats everything i changed :)

 

by: dageyraPosted on 2009-04-23 at 14:25:04ID: 24219961

Hello xSuperioRx:

Thanks, that helps a lot.  There are a few snags.  First, if I add the position: relative to the container, it causes the submenu in the menu to be off.  I found that using any position would cause this, which is why I had to avoid it.  Since position is inherited, I believe that having it in the container causes the menu CSS to also be relative, therefore screwing up the submenu pull out.

However, by removing the position: relative, both the content and the menu are in the right place in IE.  The problem, as you pointed out, is that the banner is still off.  Is there any way that I can get the banner in the right position without using the position: relative or possibly stop the inheritence down to the menuModule class?

I feel like I'm almost there!

 

by: dageyraPosted on 2009-04-23 at 14:26:12ID: 24219970

Also, it's interesting how putting in the left: 0px causes the banner to be flush with the left side, yet without it, it's way off to the right.  Surely there is some middle ground that will allow the banner to be centered properly?

 

by: xSuperioRxPosted on 2009-04-23 at 15:10:27ID: 24220265

If you keep the page like that (keeping container as relative) i think your best bets the absolute values inside the Transmenu.

Personally i tend to only use absolute values when i really really have to.

If you are still having trouble after you've looked at the transmenu divs, then i would suggest trying to build it from scratch (i know thats probably not so fun but.. :/).

Sadly i dont have anything better to come with right now. Its getting late so I'm going to go to bed again. Hopefully i've been to some use today :)

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...