Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Location
    UK
    Posts
    207
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Different CSS for IE

    I am using some different CSS to fix bugs in IE/Win.

    I have used the following code but I just wanted to make sure it does not have any problems that i've not heard about.

    Code:
    margin-top: 355px;
    _margin-top: 0px;
    Thanks

  • #2
    Regular Coder Masterslave's Avatar
    Join Date
    Dec 2005
    Posts
    287
    Thanks
    2
    Thanked 0 Times in 0 Posts
    The underscore hack is not valid CSS, use conditional comments instead:
    Code:
    <!--[if IE]><link rel="stylesheet" href="css/front/ie.css" type="text/css" media="screen" /><![endif]-->
    ie.css
    Code:
    margin-top: 0;
    What do you mean about 'any problems that i've not heard about'?

  • #3
    New to the CF scene
    Join Date
    May 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well, I like the irony of using one bug to fix another. Puritanical coders don't like it, but to be honest, I use it pretty frequently. You'll just never be able to get rid of your browser errors.

  • #4
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by phauwn
    well, I like the irony of using one bug to fix another. Puritanical coders don't like it, but to be honest, I use it pretty frequently.
    No-one I know considers conditional comments a "bug". Proprietory, yes. But a bug? Nah.

    Most developers I know, particularly the puritans, increasingly prefer the use of CCs to hacking/loading up their principle stylesheets with proprietory properties, syntax invalidations and other error-based 'filters'.

    As a bit of a puritan myself, I prefer CCs to the alternatives and wouldn't mind seeing conditional comments brought into the standard, with each UA supplying their own 2-character own ident code.
    Last edited by Bill Posters; 05-03-2006 at 07:51 AM.

  • #5
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,300
    Thanks
    28
    Thanked 275 Times in 269 Posts
    Quote Originally Posted by Bill Posters
    No-one I know considers conditional comments a "bug". Proprietory, yes. But a bug? Nah.

    As a bit of a puritan myself, I prefer CCs to the alternatives and wouldn't mind seeing conditional comments brought into the standard, with each UA supplying their own 2-character own ident code.
    Yeah, a bug is an unintended effect heh. CCs exist and function for their intended purposes and for that reason they're more reliable than hacks which tend to rely on broken CSS support and parsing bugs; when or if those are fixed down the road, those that use hacks will end up with broken pages in IE.

    I wouldn't mind seeing all browsers having a form of CCs either for the sake of convenience. However, the downside is that it might encourage browser vendors to be more lax in upholding the standards since they could just say "code for our browser specifically because we're right, problem solved". If a programmer's code wasn't working they could also just use this as a window out rather than searching for a real solution. Code that doesn't work isn't always the browser's fault; sometimes it's just bad design and poor code on the programmer's part.
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #6
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,620
    Thanks
    0
    Thanked 645 Times in 635 Posts
    The CCs are valid HTML comments. The only difference is that IE understands them as if statements to include extra code. This is no different from the way that server side includes are valid HTML comments that are replaced by the SSI parser before serving the page. Selective processing comments like this is probably the tidiest way that browser specific functionality can be handled and including CSS or Javascript inside of CCs is the ONLY way of making it specific to IE as all hacks and browser detection tests have the potential to misidentify browsers and screw things up.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •