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
- Gemini 2.0 Flash: An outstanding multi-modal LLM with a sci-fi streaming mode - 11th December 2024
- ChatGPT Canvas can make API requests now, but it's complicated - 10th December 2024
- I can now run a GPT-4 class model on my laptop - 9th December 2024