473,396 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Correct conditional comments

Hi, I'm putting some conditional comments into a page to stop Internet Explorer 6 from being the evil piece of sh!$ that it is.

I want one stylesheet for IE 6 and another for all other browsers.

So...
[HTML]
<!--[if IE 6]><link href="ie6.css" type="text/css" rel="stylesheet" /><![endif]-->[/HTML]That's easy enough. But then for all the other browsers, Microsoft suggest this:[HTML]<![if !IE 6]><link href="normal.css" type="text/css" rel="stylesheet" /><![endif]>[/HTML]But surely that's not really valid? Surely a comment needs to start with[HTML]<!--[/HTML]and end with[HTML]-->[/HTML]So I am thinking that this is a 'correct' way of doing it...[HTML]<!--[if !IE 6]--><link href="normal.css" type="text/css" rel="stylesheet" /><!--[endif]-->[/HTML]So my question is, does that work? To me it is more valid, in a W3C sense. But I don't have a computer with IE6 (or any version of IE) on it, so I can't test to see if it will do the job. If someone could test it, or if someone knows whether or not it will work, that'd be great.

Thanks
Oct 14 '08 #1
3 2228
acoder
16,027 Expert Mod 8TB
Yes, that should work and you're also correct about the original suggestion beig invalid - see link.
Oct 14 '08 #2
Thanks.. I had a search on Google for an explanation like the one in your link, but hadn't found one.

For anyone else reading this, note that according to the linked page above the valid version should be:[HTML]<!--[if !IE 6]--><link href="normal.css" type="text/css" rel="stylesheet" /><!--<![endif]-->[/HTML]

(an extra <! in the second comment). Not sure if it makes any difference.
Oct 14 '08 #3
acoder
16,027 Expert Mod 8TB
I think what they've done is add the beginning comment to the suggested version.

Since the suggested version by Microsoft is the "safer" (though invalid) method, there's no guarantee that this will work in future versions (see http://en.wikipedia.org/wiki/Conditi...tional_comment).
Oct 15 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Alf P. Steinbach | last post by:
The fourth part of my attempted Correct C++ tutorial is now available, although for now only in Word format (use free Open Office if no Word), and also, it's not yet been reviewed at all -- ...
28
by: Benjamin Niemann | last post by:
Hello, I've been just investigating IE conditional comments - hiding things from non-IE/Win browsers is easy, but I wanted to know, if it's possible to hide code from IE/Win browsers. I found...
8
by: Drew | last post by:
I am building an application for keeping track of user permissions here at work. I have built the interfaces, and am now working on the processing page for inserting to the database. I am having...
13
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which...
1
by: Martin Schneider | last post by:
Hi! I have an unbound text field conditionally formatted: =DomWert("";"ActiveLines") (DomWert is the german translation for domain value) (to check whether the currend record is within...
12
by: code break | last post by:
Hi all, Please can any one tell me the importance of below code... #if 0 /*what is use of this macro conditional.since this is every time false .*/ stmt1 ; #else
6
by: patrick j | last post by:
Hi I've been testing out the "Conditional Comment" for IE. This is because for my web-site I want to have two style sheets, one for IE 6 and one for other browsers. Thus I hope to have my...
6
by: maxwell | last post by:
I'm trying to use the gpp utility (Gnu points to http://en.nothingisreal.com/wiki/GPP) to do conditional compilation in Python, and I'm running into a problem: the same '#' character introduces...
2
by: John | last post by:
Hi there, I've just been reading "ASP.Net 2.0 - Master Pages: Tips, Tricks, and Traps" by K. Scott Allen (http://odetocode.com/Articles/450.aspx) and discovered how rebasing works with URL's in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.