Skip to main content

Powmow

Powmow 's Public Library

12 Dec 08

How to Design a CSS Web Site for Both Firefox and Internet Explorer

  • Hiding Styles from IE 6


    It's actually really easy to hide styles from IE 6 but make them visible to standards compliant browsers. Use child selectors.

    In one design I built, I created a two column layout that required margins and padding. This meant that I was hitting the box model differences when I viewed the page in IE 6. My first CSS style sheet for Firefox included a line like this:

    div#nav { width: 150px; margin-left: 20px; }

    This made the page line up perfectly in Firefox and Safari, but in IE the nav column was pushed over to the right too far.

    So, I converted the line to use child selectors. The #nav div is a child of the body tag, so I changed the line to read:

    body > div#nav { width: 150px; margin-left: 20px; }

    Of course, doing this made the #nav div lose all it's properties in IE, so I needed to add in some IE styles to get IE 6 looking okay. I added this line to the CSS:

    #nav { width: 150px; margin-left: 10px; }

    The placement of this line of CSS is important if my page is still to look good in Firefox and Safari. The IE line needs to come first. Firefox and Safari will read that line and then it will be over-ridden by the body > div#nav selector lower in the document. IE 6 will read the first line and set the styles. It will then ignore the child selector, as it doesn't recognize them. When IE 7 comes along, it will act like Firefox and Safari.

  • Hiding Styles from IE 6


    It's actually really easy to hide styles from IE 6 but make them visible to standards compliant browsers. Use child selectors.

    In one design I built, I created a two column layout that required margins and padding. This meant that I was hitting the box model differences when I viewed the page in IE 6. My first CSS style sheet for Firefox included a line like this:

    div#nav { width: 150px; margin-left: 20px; }

    This made the page line up perfectly in Firefox and Safari, but in IE the nav column was pushed over to the right too far.

    So, I converted the line to use child selectors. The #nav div is a child of the body tag, so I changed the line to read:

    body > div#nav { width: 150px; margin-left: 20px; }

    Of course, doing this made the #nav div lose all it's properties in IE, so I needed to add in some IE styles to get IE 6 looking okay. I added this line to the CSS:

    #nav { width: 150px; margin-left: 10px; }

    The placement of this line of CSS is important if my page is still to look good in Firefox and Safari. The IE line needs to come first. Firefox and Safari will read that line and then it will be over-ridden by the body > div#nav selector lower in the document. IE 6 will read the first line and set the styles. It will then ignore the child selector, as it doesn't recognize them. When IE 7 comes along, it will act like Firefox and Safari.

  • 3 more annotations...
21 Oct 06

Gmail

  • ThePoolGuy
10 Oct 06

Tea Time World Wide - Tea Tasting 101

  • Tips on Removing
    the Caffeine from Quality Tea


    Approximately 80% of the caffeine in
    tea is released during the first 30-seconds of steeping, therefore to
    remove most of the caffeine from any tea simply

    1) Pour boiling water over the tea leaves

    2) Allow the leaves to steep for 30 seconds

    3) Pour out the brew, saving the steeped leaves

    4) Re-steep the same leaves with more boiling water for the recommended
    steeping times.

1 - 20 of 612 Next › Last »
Showing 20 items per page

Highlighter, Sticky notes, Tagging, Groups and Network: integrated suite dramatically boosting research productivity. Learn more »

Join Diigo