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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:42:20+00:00 2026-05-18T11:42:20+00:00

I want to target IE7 and IE8 with W3C-compliant CSS. Sometimes fixing CSS for

  • 0

I want to target IE7 and IE8 with W3C-compliant CSS. Sometimes fixing CSS for one version does not fix for the other. How can I achieve this?

  • 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. Editorial Team
    Editorial Team
    2026-05-18T11:42:21+00:00Added an answer on May 18, 2026 at 11:42 am

    Explicitly Target IE versions without hacks using HTML and CSS

    Use this approach if you don’t want hacks in your CSS. Add a browser-unique class to the <html> element so you can select based on browser later.

    Example

    <!doctype html>
    <!--[if IE]><![endif]-->
    <!--[if lt IE 7 ]> <html lang="en" class="ie6">    <![endif]-->
    <!--[if IE 7 ]>    <html lang="en" class="ie7">    <![endif]-->
    <!--[if IE 8 ]>    <html lang="en" class="ie8">    <![endif]-->
    <!--[if IE 9 ]>    <html lang="en" class="ie9">    <![endif]-->
    <!--[if (gt IE 9)|!(IE)]><!--><html lang="en"><!--<![endif]-->
        <head></head>
        <body></body>
    </html>
    

    Then in your CSS you can very strictly access your target browser.

    Example

    .ie6 body { 
        border:1px solid red;
    }
    .ie7 body { 
        border:1px solid blue;
    }
    

    For more information check out http://html5boilerplate.com/

    Target IE versions with CSS “Hacks”

    More to your point, here are the hacks that let you target IE versions.

    Use “\9” to target IE8 and below.
    Use “*” to target IE7 and below.
    Use “_” to target IE6.

    Example:

    body { 
    border:1px solid red; /* standard */
    border:1px solid blue\9; /* IE8 and below */
    *border:1px solid orange; /* IE7 and below */
    _border:1px solid blue; /* IE6 */
    }
    

    Update: Target IE10

    IE10 does not recognize the conditional statements so you can use this to apply an “ie10” class to the <html> element

    <!doctype html>
        <html lang="en">
        <!--[if !IE]><!--><script>if (/*@cc_on!@*/false) {document.documentElement.className+=' ie10';}</script><!--<![endif]-->
            <head></head>
            <body></body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So sometimes (oftentimes!) you want to target a specific .NET version (say 3.0), but
I'm not sure how to target the element I want in this case: var
I am trying to target tablets with a own css however I do not
If I want to target all iOS devices version 4.3 or later, I can
So I want to target one specific device token via Urban Airship, but no
i want to target closest div from my anchor tag. so in order do
I want to target an HTML element when BOTH the id and class selectors
I can check for iPhone with this code: (navigator.userAgent.match(/iPhone/i)) But I want to target
I want to make a target in my MSBuild script that: Fetch SVN revision/datetime
I want preserve original value of target field and use json_decode to use following

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.