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
- Notes from Bing Chat—Our First Encounter With Manipulative AI - 19th November 2024
- Project: Civic Band - scraping and searching PDF meeting minutes from hundreds of municipalities - 16th November 2024
- Qwen2.5-Coder-32B is an LLM that can code well that runs on my Mac - 12th November 2024