- From: Tom James <TJames@salisbury.gov.uk>
- Date: Fri, 27 Jun 2003 16:46:53 +0100
- To: "'Scarlett Julian (ED)'" <Julian.Scarlett@sheffield.gov.uk>, w3c-wai-ig@w3.org
Julian Scarlett wrote ... "Another alternative is to take advantage of IE's conditional HTML comments to serve up a completely different style sheet for all or certain versions of IE. I tried doing that as an experiment and it seems to work OK. If anyone knows of any accessibility base reasons not to use conditional comments then please could they let me know." Funnily enough, I was looking into this only yesterday, pondering various "cox model hacks" and other things on a redesign of my own site. As I understand it, there are two syntaxes for writing these comments. One reads something like: <!--[If IE5]> IE 5 _only_ will get this code (including any amount of markup) <![ENDIF]--> This is a valid HTML comment (from <!-- to -->) so I can't see an _accessibility_ reason why it may be a problem. There may be problems with bandwidth (because you are sending redundant code to browsers who can't use it). There shouldn't be a forward compatibility problem, because even if MS dropped support for this form of scripting in future versions of IE - if any ever arrive - they couldn't retrospectively remove the support form the installed base of IE5. The other syntax for writing the comment is be: <![If IE5]> All browsers will get this (including markup) _except IE5_ <![ENDIF]> This looks a lot more problematic to me, as the comments are not proper comments. You are making an assumption about how [Random browser X] will treat these "comments" - for example, will they erroneously treat them as comments and hide what is between; will they treat the comments as unrecognised tags and render what is between, as MS hope, or some other behaviour? So I think this method would be flaky on any kind of accessibility / future proofing grounds. If you are trying to specifically exclude code from IE5, you could always rewrite to use the first syntax: <!--[If !IE5]> All MS browsers except IE 5 will get this code. Of course, it is hidden to non-IE browsers ... <![ENDIF]--> So fairly rapidly it gets complex and server-side detection starts to look enticing - if you have scripting rights on your server, that is ... See http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/ove rview/ccomment_ovw.asp for MS' documentation. My view is that it could be useful for detecting IE5 unambiguously, but probably not for anything more complex. The most commonly used situation is indeed for some kind of Box Model Hack: <link rel="stylesheet" type="text/css" href="standards-compliant-boxmodel.css"> <!--[If IE5]> <link rel="stylesheet" type="text/css" href="IE5-boxmodel.css"> <![ENDIF]--> There are other ways of sending correct box model widths to various target browsers (the Tantek Hack; the Caio Hack; the Simplified Box Model Hack etc.) All have advantages and disadvantages, at least from a CSS point of view. Fundamentally, however, they all require writing two widths for a given box - one for IE 5, one for compliant browsers (including IE6 if you force it into standards mode), so arguments about one mechanism or another simplifying maintenance don't wash for me - all require maintenance of two separate values, whether in two separate stylesheets or twice in one stylesheet. For someone who in future has to maintain the site (perhaps not the initial author) I think the conditional comments mechanism (or a server-scripted variation) at least has the advantage of being intuitively clearer than the variations that rely on some kind of CSS parsing bug to work - but that is just my view. Tom ============================================ Dr Tom James Corporate e-Government Officer Salisbury District Council 3 Rollestone Street Salisbury SP1 1DX "Internet Communications are not necessarily secure, and therefore Salisbury District Council does not accept legal responsibility for the contents of this message. Any views or opinions presented are those of the author and do not necessarily represent those of Salisbury District Council. Anyone replying by email to the author of this message (or emailing anyone else, using the "@salisbury.gov.uk" address), is advised that such emails may be read by persons other than the intended recipient" ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Received on Friday, 27 June 2003 11:47:20 UTC