10 Replies Latest reply on Apr 20, 2015 1:24 AM by ScottHacel

    How do i link my conditional stylesheets?

    ScottHacel Level 1

      Im trying to link a conditional stylesheet for IE and it doesn't seem to be working. I'm using this comment;

       

      <!--[if lte IE 9]>

      <link rel="stylesheet" href="stylesheet.css">

      <![endif]-->

       

      However i cannot get the stylesheet to appear across the top with the other style sheets. Should it appear the same? Plus when  i press " to try and link it offers no browse option to link the stylesheet. Is there something I'm doing wrong?

       

      Cheers.

        • 1. Re: How do i link my conditional stylesheets?
          MurraySummers Level 8

          I don't think you will see any conditionally linked file as a related file - after all those conditional comments are really just HTML comments and only understood by IE. It's an interesting idea, though.

          • 2. Re: How do i link my conditional stylesheets?
            Rob Hecker2 Adobe Community Professional & MVP

            You could use the PHP HTTP_USER_AGENT or the javascript window.navigator.appName to identify the browser, and load the CSS file using either of those languages.

             

            Note, however, that IE11 can't be identified in the same way earlier versions of IE are. If you don't care about identifying IE11, then you can search for "MSIE" in the user agent string.

             

            There are plenty of examples and discussions regarding using these two languages to identify Internet Explorer. I'm sure a google search will provide you with good sample code.

            1 person found this helpful
            • 3. Re: How do i link my conditional stylesheets?
              ScottHacel Level 1

              So will the only really to check if they have worked is to see them within the browser?

              • 4. Re: How do i link my conditional stylesheets?
                MurraySummers Level 8

                Yes - preview the page in the respective browser.

                • 5. Re: How do i link my conditional stylesheets?
                  Jon Fritz II Adobe Community Professional & MVP

                  MurraySummers wrote:


                  Yes - preview the page in the respective browser.

                   

                  Which is the only way to ever truly tell what your page actually looks like in a given browser. Keep in mind, Live View is just a "mostly there" Webkit browser (Chrome or Safari). If you're not previewing in the actual browsers you intend to support (especially older IE), it's possible to miss the subtle, and not so subtle differences between them pretty easily during development.

                  • 6. Re: How do i link my conditional stylesheets?
                    ScottHacel Level 1

                    Thanks for the help i have managed to get the stylesheet working and am now working on the many little issues that come with attempting to support older IE versions

                    • 7. Re: How do i link my conditional stylesheets?
                      Jon Fritz II Adobe Community Professional & MVP

                      ScottHacel wrote:

                       

                      Thanks for the help i have managed to get the stylesheet working and am now working on the many little issues that come with attempting to support older IE versions

                       

                      Ah, so you're getting to the part where you vocabulary simplifies to a handful of four-letter words, your hair comes out by the fistful and you  constantly mutter under your breath about the things you would do if you met one of Microsoft's development team?

                       

                      Keep in mind, most sites have a very, very low number of users viewing them in anything under IE9. Even IE9 itself is dropping off extremely quickly. All of that pent up rage being created by trying to develop for old IE may be self inflicted for no good reason. Make sure you know your viewership numbers for those old browsers.

                       

                      Personally, I completely ignore any browser under about 2-3% viewership on my sites which, for the vast majority of sites I develop/maintain, includes everything IE8 and lower (and IE9 on most of them), Opera and all Windows versions of Safari. Even IE 10 is approaching "don't care" on a few of them.

                       

                      It seems people have made the old joke that "IE is the best browser to download other browsers with" factually accurate.

                      1 person found this helpful
                      • 8. Re: How do i link my conditional stylesheets?
                        Nancy OShea Adobe Community Professional & MVP

                        i have managed to get the stylesheet working and am now working on the many little issues that come with attempting to support older IE versions

                        Scott,

                        If somebody is still using IE7 or 8, they know their web experience is not the best it could be. 

                        Put this inside your conditional comment.

                        IE8-end-of-life.jpg

                         

                        Nancy O.

                        • 9. Re: How do i link my conditional stylesheets?
                          osgood_ Level 8

                          ScottHacel wrote:

                           

                          Im trying to link a conditional stylesheet for IE and it doesn't seem to be working. I'm using this comment;

                           

                          <!--[if lte IE 9]>

                          <link rel="stylesheet" href="stylesheet.css">

                          <![endif]-->

                           

                          However i cannot get the stylesheet to appear across the top with the other style sheets. Should it appear the same? Plus when  i press " to try and link it offers no browse option to link the stylesheet. Is there something I'm doing wrong?

                           

                          Cheers.

                           

                          I don't know why youre wasting time using conditional comments any longer. Back in the days when pre IE8/9 were vital to support sure but now I don't bother with anything less than IE9 any longer. I havent really seen a 'current' website that does apart from those that want to make the new html5 tags compatible (the only real reason to use a conditional comment nowdays). Browser descrepancies largely dispppeared after IE8 died and those that remain are not a big issue as to want to cater for them by using a conditional comment. Certainly no real reason to be serving them an alternative stylesheet UNLESS of course you want the website to look completely different in a particular browser.

                          1 person found this helpful
                          • 10. Re: How do i link my conditional stylesheets?
                            ScottHacel Level 1

                            Thanks for all the Advice! I will probably move on and ignore IE8 or later.