13 replies [Last post]
Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 1 week 2 hours ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5344
Points: 2965

Early on in web development we were encouraged to use browser detection scripts to feed css or javascript to supporting browsers.
Then that became a no no, it was better to detect functionality support in browsers before using the scripts or use css hacks to give styles to the correct browsers.
Now it looks as if we are moving in another direction with IE7 on it's way.
The Internet Explorer blog is encouraging the use of conditional comments to stop our sites, hacked to work in IE <=6 falling over in IE7.
Conditional comments have been something I have avoided using mainly because they are Microsoft proprietary elements. If they were supported by all browsers, not just ignored by them, they may have been useful. Even better would have been a similar CSS Conditional Comment.

Here's a list of CSS hacks that could cause problems in IE7:

How many sites have you built over the last couple of years using one or more of those hacks :?:

[/]
gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 2 years 3 weeks ago
Dallas
Timezone: GMT-6
Joined: 2004-06-25
Posts: 9776
Points: 3858

Conditional Comments

Looking at my own use of hacks, I see nearly all are either the star hack or child selector. Related to this,

  1. IE7 will cure most if not all of the hasLayout dependent bugs—Big John's list.

  • IE7 will ignore the star hack.
  • IE7 will honor the sibling, child, etc. selectors.
  • From this, it seems IE7 will ignore the hacks that Firefox, et al. ignore, and will respond to the hacks that modern browsers respond to. I don't see that anything I'm doing will be a problem.

    I do foresee problems if MS doesn't fix something that needs, say, the Holly hack. In that case we will have to use conditional comments. I don't like the idea of proprietary markup, but don't see an alternative. I understand if they can't bring IE completely up to date, I just want them to make what they do support work correctly.

    cheers,

    gary

    [/]

    If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

    Hugo
    Hugo's picture
    Offline
    Moderator
    London
    Last seen: 8 years 11 weeks ago
    London
    Joined: 2004-06-06
    Posts: 15668
    Points: 2806

    Conditional Comments

    Like Gary I tend to use very few hacks and when I do they are chiefly star selector and Child.

    So if the problems that the Star selector addresses are cleared up and the Star selector ignored in IE7 I don't see major problems despite the alarmist warnings that the Star selector is deprecated, do not use[css-discuss].

    The problems seem to be with the fact that MS are still going to preserve white space for empty elements ( but they were the first to implement this and so are right!) whilst the W3C says empty elements should be ignored. So the problem arises as demonstrated on the MSDN Blog where a child selector is used to feed normal margins and then a second rule set feeds a negative margin to compensate for IE white space. This hack now falls apart as IE7 reads the child selector.

    There is no apparent way now of hacking this that I have been able to see, other than as said to have to pull the rule out and wrap it in MS conditional comments; so we now have a second stylesheet or extra bulk in the header of each page, not ideal.

    I'm no lover of hacks and seem to manage with surprisingly few by being carful and not using them to correct bad use of CSS properties, but whilst there are these sorts of major differences in the way IE treats certain aspects of rendering I would feel happier knowing that I still had something to use.

    Hugo.

    Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
    ----------------------------------------------------------------
    Please post ALL your code - both CSS & HTML - in [code] tags
    Please validate and ensure you have included a full Doctype before posting.
    Why validate? Read Me

    manuelrazzari
    Offline
    newbie
    Buenos Aires, Argentina
    Last seen: 17 years 22 weeks ago
    Buenos Aires, Argentina
    Timezone: GMT-3
    Joined: 2005-10-26
    Posts: 1
    Points: 0

    clearfix and IE7

    I'm left wondering... Tony's clearfix method on IE relies on the "auto-clearing" of floats, that is, a violation of the spec. So, what if this is fixed on IE7, AND they don't add after support?
    (Or is this just one of the countless compatibility questions that will remain unanswered until IE7 beta 2?)

    Tony
    Tony's picture
    Offline
    Moderator
    Brisbane
    Last seen: 1 week 2 hours ago
    Brisbane
    Timezone: GMT+10
    Joined: 2003-03-12
    Posts: 5344
    Points: 2965

    Conditional Comments

    Hi manuelrazzari,
    That is an interesting question.
    The technique will continue to work on current browsers but may need to be modified or hidden from IE7.

    We will have to wait and see what IE7 brings us.

    Cyberman
    Cyberman's picture
    Offline
    Regular
    Last seen: 18 years 6 weeks ago
    Joined: 2005-02-11
    Posts: 37
    Points: 0

    Re: Conditional Comments

    Tony wrote:
    Conditional comments have been something I have avoided using mainly because they are Microsoft proprietary elements.

    True, but they can be masked as comments. So they won´t cause problems in other browsers.

    Quote:
    If they were supported by all browsers, not just ignored by them, they may have been useful. Even better would have been a similar CSS Conditional Comment.

    Most definitely. Though I fear that a consistend HTML-way of detecting the browser would lead to the construction of multiple html pages, instead of merely "correcting" the existing one.

    I personally prefer CC - I think it´s a cleaner way to use something that acts like comments, instead of hoping that only one browser misunderstands certain elements.

    Chris..S
    Chris..S's picture
    Offline
    Moderator
    Last seen: 10 years 27 weeks ago
    Timezone: GMT+1
    Joined: 2005-02-22
    Posts: 6078
    Points: 173

    Re: clearfix and IE7

    manuelrazzari wrote:
    I'm left wondering... Tony's clearfix method on IE relies on the "auto-clearing" of floats, that is, a violation of the spec. So, what if this is fixed on IE7, AND they don't add :after support?
    (Or is this just one of the countless compatibility questions that will remain unanswered until IE7 beta 2?)

    I believe, IE7 claims they will support the :after selector.

    Hugo seems to have correctly identified the main problem. IE7 seem to have shown a commitment to remove IE6 bugs and to give as good a support for CSS2.1 selectors as any browser. If that is the case, the problem will be where the IE7 team is happy to implement what they consider a compliant behaviour but in a different manner from the method chosen by other compliant browsers.

    Chris..S
    Chris..S's picture
    Offline
    Moderator
    Last seen: 10 years 27 weeks ago
    Timezone: GMT+1
    Joined: 2005-02-22
    Posts: 6078
    Points: 173

    Re: Conditional Comments

    Cyberman wrote:
    I personally prefer CC - I think it´s a cleaner way to use something that acts like comments, instead of hoping that only one browser misunderstands certain elements.

    Yes. It would be good if other browsers supported it too. Although it probably would never make it into the standard its a real life concession that sometimes different browsers may behave differently.

    Only problem would be, some browsers would then decide they should handle another browsers CCs.

    Hugo
    Hugo's picture
    Offline
    Moderator
    London
    Last seen: 8 years 11 weeks ago
    London
    Joined: 2004-06-06
    Posts: 15668
    Points: 2806

    Conditional Comments

    I think all sorts of nightmare scenarios would develope if everyone started to implement their own conditional comments you might as well be coding completely separate stylesheets.

    Chris's statement "where the IE7 team is happy to implement what they consider a compliant behavior but in a different manner from the method chosen by other compliant browsers." is the crux of the problem as MS clearly still think that they are right on certain aspects and that the W3C are wrong and thus do they still demonstrate the desire to not comply fully with a unified standard; the white space issue is a case in point where MS clearly state that they were first to implement this behavior of honouring white space for empty elements and seemingly are not going to consider complying with the perceived standard, creating a new set of problems in their desire to be seen to fix up CSS support. They are a funny lot.

    Hugo.

    Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
    ----------------------------------------------------------------
    Please post ALL your code - both CSS & HTML - in [code] tags
    Please validate and ensure you have included a full Doctype before posting.
    Why validate? Read Me

    fambi
    Offline
    Enthusiast
    Last seen: 14 years 44 weeks ago
    Joined: 2004-08-26
    Posts: 269
    Points: -1

    Conditional Comments

    This discussion seems to be inbetween a whole load of pro's, so sorry if i join.

    I just learned about the * html hack today which i need for one element's width which is not rendering as desired in IE6.

    So, am i right or wrong in understanding that IE7 will ignore this and render it just as FF and NS are and that there is nothing to worry about?

    Chris..S
    Chris..S's picture
    Offline
    Moderator
    Last seen: 10 years 27 weeks ago
    Timezone: GMT+1
    Joined: 2005-02-22
    Posts: 6078
    Points: 173

    Conditional Comments

    fambi wrote:
    So, am i right or wrong in understanding that IE7 will ignore this and render it just as FF and NS are and that there is nothing to worry about?

    Pretty much yes. I don't know that any of us here has seen IE7, but the IE7 blog is written by people close to/involved in IE7 development and it claims as much.

    To explain a little.

    * html someselector, while syntactically correct, is invalid in the (X)HTML context. html is the root element so can not be descended from any other element. This "bug" with IE6 and earlier versions is one of those identified as to be (been?) fixed in IE7.

    fambi
    Offline
    Enthusiast
    Last seen: 14 years 44 weeks ago
    Joined: 2004-08-26
    Posts: 269
    Points: -1

    Conditional Comments

    Thanks for clearing that up.

    ClevaTreva
    ClevaTreva's picture
    Offline
    Guru
    A hilly place, UK
    Last seen: 4 years 21 weeks ago
    A hilly place, UK
    Joined: 2004-02-05
    Posts: 2902
    Points: 0

    Now, wouldn't it be nice if MS .... ?

    Put a nice little option on the install dialog.

    If you would rather have a reliable and solid browser don't click I Accept and don't install, instead, GET FIREFOX!

    Trevor

    nix
    nix's picture
    Offline
    Enthusiast
    (n): a position or site occupied or available for occupancy or marked by some distinguishing feature
    Last seen: 13 years 43 weeks ago
    (n): a position or site occupied or available for occupancy or marked by some distinguishing feature
    Timezone: GMT-4
    Joined: 2003-08-12
    Posts: 159
    Points: 0

    Re: Now, wouldn't it be nice if MS .... ?

    ClevaTreva wrote:
    Put a nice little option on the install dialog.

    If you would rather have a reliable and solid browser don't click I Accept and don't install, instead, GET FIREFOX!

    Trevor

    You're a clever one. Are you by chance related to Magical Trevor? Tongue

    I refuse to be like the faceless masses of sheep and have a signatu......awwwwwwwww CRAP!!

    Backups? Ha! I've never had troub**&{[}$$ERROR NO CARRIER