SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2008
    Location
    Central New Jersey
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    IE conditional statements...how are they utilized?

    Hello mentors of the world's domains,

    I often use dreamweaver to generate an initial layout .css file or style sheet, as well as an html document with the choice of markup being utilized, and basic page div structure implemented, from which point i use a code editor and code the rest of the site pages by hand.

    Often times this page is generated to include the following conditional statements for various IE versions
    Code:
    <!--[if IE 5]>
    <style type="text/css"> 
    /* place css box model fixes for IE 5* in this conditional comment */
    .thrColFixHdr #sidebar1 { width: 180px; }
    .thrColFixHdr #sidebar2 { width: 190px; }
    </style>
    <![endif]--><!--[if IE]>
    <style type="text/css"> 
    /* place css fixes for all versions of IE in this conditional comment */
    .thrColFixHdr #sidebar2, .thrColFixHdr #sidebar1 { padding-top: 30px; }
    .thrColFixHdr #mainContent { zoom: +1; }
    /* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
    </style>
    <![endif]-->
    My question is, do these statement need to be "un-commented" to work? Or are they meant to be left as they are as written?

    I ask because this is the case with the current site i am working on, and although my IE8 renders the divs properly, the client's IE7 displays parts of the header div well in to the main content area, so i switched some of the element divs to terminate the header prior to the navbar for which she replied it was now where it should be, the problem is, often times when trying to position some elements, FF and IE are not synchronous in their needs for the same result, so when accommodating FF browsers, and not seeing any different on MY IE how am I to know if it displays right or is "backwards compatible" with earlier browser versions?

    So are these statements meant to compensate for such inadequacies, and should they be uncommented out, and do i do it to both of them or just choose one?

    Also do I need to revise the settings defined in those statements if I am changing the actual widths of the containers referenced?

    Thanks in advance for any help clarifying this!

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,608
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Nothing needs to be uncommented as those "comments" use a special Microsoft format that Microsoft programs such as IE and office recognise as IF statements rather than comments and therefore include the appropriate section of content depending on whether the if statement corresponds to the current version of IE or office. They will still work if you get rid of the leading !-- or trailing -- provided you only use the code with Microsoft programs but you need to make them into HTML comments so that non-Microsoft programs will treat them as comments.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    Follow: @AlexDawsonUK silver trophybronze trophy AlexDawson's Avatar
    Join Date
    Feb 2009
    Location
    England, UK
    Posts
    8,111
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Just as an additional note it also makes sense to treat them as comments for the sake of any validation you choose to do, the W3C validator will see them simply as HTML comments and will float under the radar unhindered but of course Internet Explorer will pick up on it, it ensures we have a solid way of working round the browser without nasty hacks which mess with other browsers, conditional comments are only visible to browsers which choose to employ them

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2008
    Location
    Central New Jersey
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    WOW thanks guys, I know it was awhile ago I posted this and you responded, but I have been swamped, and had to get back here to express my appreciation of your clarifying this for me.

    I really did appreciate it, sorry for it taking so long to respond.


Tags for this Thread

Bookmarks

Posting Permissions

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