1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Validation problem

Discussion in 'HTML & Website Design' started by mcfc4eva, Mar 19, 2009.

  1. #1
    I had to include the following code in a website to make it crossbrowser compatible but it doesn't validate.

    <![if !IE]><style> #nav ul { top:-4px;}</style><![endif]>
    Code (markup):
    I believe it doesn't validate simply because it isn't XHTML, it's another language, but what language is it and how can I make it validate?

    Thanks,
    Michael
     
    mcfc4eva, Mar 19, 2009 IP
  2. mcfc4eva

    mcfc4eva Well-Known Member

    Messages:
    602
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Does it even matter that it throws up validation errors on this, so long as the rest of the page is valid?
     
    mcfc4eva, Mar 19, 2009 IP
  3. belkocrnic

    belkocrnic Active Member

    Messages:
    107
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Use <!--[if !IE]><style> #nav ul { top:-4px;}</style><![endif]-->. I think that will solve your problem
     
    belkocrnic, Mar 19, 2009 IP
  4. mcfc4eva

    mcfc4eva Well-Known Member

    Messages:
    602
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    110
    #4
    Thanks belkocrnic but it didn't work. Instead it just made the statement into a comment and thus ignored it.

    Any other suggestions?
     
    mcfc4eva, Mar 19, 2009 IP
  5. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #5
    That is correct. These are IE Conditional Comments and do not work with any other browser so !IE statement doesn't make sense.
     
    drhowarddrfine, Mar 19, 2009 IP
  6. CoryR

    CoryR Active Member

    Messages:
    68
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    70
    #6
    My recommendation: Instead of relying of conditional statements use JavaScript to provide you with specific browser selectors.
     
    CoryR, Mar 19, 2009 IP
  7. mcfc4eva

    mcfc4eva Well-Known Member

    Messages:
    602
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    110
    #7
    Ahh, that makes sense now. I can fix this by doing a little tweaking and changing !IE to IE then. Thanks drhowarddrfine!

    Just out of curiousity, are there any conditional statements that apply to other browsers such as FF and Opera that are still W3C valid?
     
    mcfc4eva, Mar 19, 2009 IP
  8. CoryR

    CoryR Active Member

    Messages:
    68
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    70
    #8
    Only IE supports conditional statements.
     
    CoryR, Mar 19, 2009 IP
  9. mcfc4eva

    mcfc4eva Well-Known Member

    Messages:
    602
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    110
    #9
    Really? Well the original statement (in my first post) works in FF at the very least - it just doesn't validate.
     
    mcfc4eva, Mar 20, 2009 IP
  10. Spawny

    Spawny Well-Known Member

    Messages:
    252
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    110
    #10
    try

    <![if !IE]><style type="text/css"> #nav ul { top:-4px;}</style><![endif]>
     
    Spawny, Mar 20, 2009 IP
  11. mcfc4eva

    mcfc4eva Well-Known Member

    Messages:
    602
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    110
    #11
    Thanks Spawny but it's the actual condition (and the syntax of the condition) and not the statement itself that is throwing up the errors.
     
    mcfc4eva, Mar 20, 2009 IP
  12. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #12
    Instead of trying to make that rubbish hack work, perhaps you could just fix the page in question? Usually if you need to make that type of adjustment, there's bigger problems with the layout.
     
    deathshadow, Mar 20, 2009 IP
  13. mcfc4eva

    mcfc4eva Well-Known Member

    Messages:
    602
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    110
    #13
    The site is fine, it's just how the FF and IE processes padding/margins differently.
     
    mcfc4eva, Mar 20, 2009 IP
  14. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #14
    99.99% of the time if they are handling margins/padding differently, you either don't have a doctype, overthought your layout, or are 'doing it all wrong'.
     
    deathshadow, Mar 20, 2009 IP
  15. mcfc4eva

    mcfc4eva Well-Known Member

    Messages:
    602
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    110
    #15
    That's not helpful... at all.
     
    mcfc4eva, Mar 24, 2009 IP
  16. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #16
    For future reference, I was shown the site via PM, and the problem with the page in question was an XML prolog throwing IE into quirks mode combined with margin use tripping the buggy box model.
     
    deathshadow, Mar 24, 2009 IP
    mcfc4eva likes this.
  17. mcfc4eva

    mcfc4eva Well-Known Member

    Messages:
    602
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    110
    #17
    Thanks deathshadow for giving a few very valuble pointers by PM. very greatful for this :)
     
    mcfc4eva, Mar 24, 2009 IP