Safari conditional comments
11th January 2003
The current extended discussion over whether or not Safari should have some kind of specific CSS blocking technique built in (sparked off by Mark Pilgrim) reminds me of a relatively unpublicised feature of Internet Explorer called conditional comments. These specially crafted HTML comments allow web authors to specifically hide code from versions of IE, or alternatively to hide code from any browsers that are not a specified version of IE. Here’s how they work:
<![if !IE 5]> <p>This HTML only visible to non-Microsoft browsers or IE versions older than IE 5</p> <![endif]> <!--[if IE 5.0]> <p>This HTML only visible to IE version 5</p> <![endif]-->
The downside of this approach is that it encourages ugly browser specific code to be added to the HTML of a page. Adrian Holovaty’s suggestion for Safari is similar but, in my opinion, more elegant as the unpleasant code is restricted to the stylesheet (I always prefer nasty hacks to stay out of the way in the stylesheet rather than rearing their ugly heads in my markup)
More recent articles
- My AI/LLM predictions for the next 1, 3 and 6 years, for Oxide and Friends - 10th January 2025
- Weeknotes: Starting 2025 a little slow - 4th January 2025
- I still don't think companies serve you ads based on spying through your microphone - 2nd January 2025