473,287 Members | 1,533 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,287 software developers and data experts.

Conditional Comment, it works, but why?

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 web-site as I want it for
"other browsers" but still have it presentable in IE.

I understand why the conditional comment works, despite the subject
header for this posting. What I don't understand is why IE "ignores"
the link to the CSS that precedes the conditional comment link.

Now that I've got you transfixed with interest I will give you the URL
to my conditional comment test web-page:

<http://www.patrickjames.me.uk/cond_com_test.html>

Fortunately it is at least a very positive message.

Viewed with IE/Win 6 or 5 the background is maroon, the text is white.
Viewed with any other browser then the background is white the text is
maroon.

I have the "Link" tags in the HTML header section arranged like this:

<link href="cond_com_test.css" rel="stylesheet" type="text/css">
<!--[if lt IE 7]>
<link href="cond_com_test_ie.css" rel="stylesheet" type="text/css" >
<![endif]-->

As you can see the link to the "other browser" style-sheet comes before
the one within the conditional comment for IE/Win 5/6.

I understand that IE makes a decision on the basis of the conditional
comment, it's programmed to recognise it, but what I don't understand
is how it knows to ignore the link to the style-sheet for other
browsers which comes first?

Ideally I would just be glad it works and not wonder about this I guess
:)

--
Patrick
Brighton, UK

<http://www.patrickjames.me.uk>

Oct 24 '06 #1
6 2052
patrick j wrote:
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 web-site as I want it for
"other browsers" but still have it presentable in IE.

I understand why the conditional comment works, despite the subject
header for this posting. What I don't understand is why IE "ignores"
the link to the CSS that precedes the conditional comment link.

Now that I've got you transfixed with interest I will give you the URL
to my conditional comment test web-page:

<http://www.patrickjames.me.uk/cond_com_test.html>

Fortunately it is at least a very positive message.

Viewed with IE/Win 6 or 5 the background is maroon, the text is white.
Viewed with any other browser then the background is white the text is
maroon.

I have the "Link" tags in the HTML header section arranged like this:

<link href="cond_com_test.css" rel="stylesheet" type="text/css">
<!--[if lt IE 7]>
<link href="cond_com_test_ie.css" rel="stylesheet" type="text/css" >
<![endif]-->

As you can see the link to the "other browser" style-sheet comes before
the one within the conditional comment for IE/Win 5/6.

I understand that IE makes a decision on the basis of the conditional
comment, it's programmed to recognise it, but what I don't understand
is how it knows to ignore the link to the style-sheet for other
browsers which comes first?
It doesn't, it applies cond_com_test.css first then redefines by
applying cond_com_test_ie.css. You would ge a very different result if
your markup was:

<!--[if lt IE 7]>
<link href="cond_com_test_ie.css" rel="stylesheet" type="text/css" >
<![endif]-->

<link href="cond_com_test.css" rel="stylesheet" type="text/css">
--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Oct 24 '06 #2
patrick j wrote:
Now that I've got you transfixed with interest I will give you the URL
to my conditional comment test web-page:

<http://www.patrickjames.me.uk/cond_com_test.html>

Fortunately it is at least a very positive message.

Viewed with IE/Win 6 or 5 the background is maroon, the text is white.
Viewed with any other browser then the background is white the text is
maroon.

I have the "Link" tags in the HTML header section arranged like this:

<link href="cond_com_test.css" rel="stylesheet" type="text/css">
<!--[if lt IE 7]>
<link href="cond_com_test_ie.css" rel="stylesheet" type="text/css" >
<![endif]-->

As you can see the link to the "other browser" style-sheet comes before
the one within the conditional comment for IE/Win 5/6.

I understand that IE makes a decision on the basis of the conditional
comment, it's programmed to recognise it, but what I don't understand
is how it knows to ignore the link to the style-sheet for other
browsers which comes first?
What leads you to think IE is ignoring the first LINK? It's processing
both, just as it would if you didn't have the conditional comments at all.
Oct 24 '06 #3

patrick j wrote:
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 web-site as I want it for
"other browsers" but still have it presentable in IE.

I understand why the conditional comment works, despite the subject
header for this posting. What I don't understand is why IE "ignores"
the link to the CSS that precedes the conditional comment link.

Now that I've got you transfixed with interest I will give you the URL
to my conditional comment test web-page:

<http://www.patrickjames.me.uk/cond_com_test.html>

Fortunately it is at least a very positive message.

Viewed with IE/Win 6 or 5 the background is maroon, the text is white.
Viewed with any other browser then the background is white the text is
maroon.

I have the "Link" tags in the HTML header section arranged like this:

<link href="cond_com_test.css" rel="stylesheet" type="text/css">
<!--[if lt IE 7]>
<link href="cond_com_test_ie.css" rel="stylesheet" type="text/css" >
<![endif]-->

As you can see the link to the "other browser" style-sheet comes before
the one within the conditional comment for IE/Win 5/6.

I understand that IE makes a decision on the basis of the conditional
comment, it's programmed to recognise it, but what I don't understand
is how it knows to ignore the link to the style-sheet for other
browsers which comes first?

Ideally I would just be glad it works and not wonder about this I guess
Ypu are giving two conflicting commands. You must both tell what to do
if IE and what to do if not IE. There is a IE not command, but it is
not valid html. However, there is a way around this that will validate
at W3C. For example, see
http://www.cwdjr.info/broadbandMedia.../cancanWMV.php . This
page takes an ActiveX object path if IE is present and an ordinary
object path if IE is not present. Note this page requires a rather high
rate broadband connection to buffer in a reasonable time, and if the
browser is IE, ActiveX must be on. Also a WMP must be installed.

The code of interest here is:

<!--[if IE]>
<div style="text-align:center">
<object id="player"
classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" height="340"
width="400">
<param name="URL" value="http://www.cwdjr.info/movie/cancanvbr.wvx" />
<param name="autoStart" value="false" />
<param name="playCount" value="1" />
<param name="volume" value="100" />
<param name="balance" value="0" />
<param name="stretchToFit" value="true" />
</object>
</div>
<![endif]-->

<!--[if !IE]<-->
<div style="text-align:center">
<object data="http://www.cwdjr.info/movie/cancanvbr.wvx"
type="video/x-ms-wvx" style="width:400px; height:340px">
<param name="src" value="http://www.cwdjr.info/movie/cancanvbr.wvx"
valuetype="ref" />
<param name="showcontrols" value="1" valuetype="data" />
<param name="showstatusbar" value="1" valuetype="data" />
<param name="autostart" value="0" valuetype="data" />
<param name="volume" value="0" valuetype="data" />
<param name="PlayCount" value="1" valuetype="data" />
</object>
</div>
<!--><![endif]-->

Nite the <!--[if !IE]<--which is closed by <!--><![endif]--to
take the correct path if not IE and to also validate at W3C.

Oct 24 '06 #4
In article
<00*****************************@News.Individual.N et>,
patrick j <pa*****@jamesnews.orangehome.co.ukwrote:
>
I understand why the conditional comment works, ... What
I don't understand is why IE "ignores"
the link to the CSS that precedes the conditional comment link.

Think of a single stylesheet, and two instructions:

div {

padding: 5px;
padding: 40px:
}

Browser reads both but resolves to the last instruction. You get
big padding!

But with

div {

padding: 40px;
padding: 5px:
}

you get modest padding.

Similar thing with stylesheet declarations in the head, the last
one is the one that counts (if it is can be understood!)

--
dorayme
Oct 24 '06 #5

patrick j wrote:
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.
You have too much in cond_com_test_ie.css

Don't write "two stylesheets" here. Write one stylesheet for the site,
for all standards-compliant browsers, then write the minimal set of
fix-ups for IE and apply only those through the conditional mechanism.

I know of only _one_ property that's justified to go in here! Anything
else you can fix by good CSS authoring practice and using
standards-mode rendering.

Oct 25 '06 #6
On Wed, 25 Oct 2006 11:28:07 +0100, Andy Dingley wrote
(in article <11**********************@i42g2000cwa.googlegroups .com>):
Don't write "two stylesheets" here. Write one stylesheet for the site,
for all standards-compliant browsers, then write the minimal set of
fix-ups for IE and apply only those through the conditional mechanism.
Thanks to all who have responded. Together the replies have given me a
great deal of knowledge I did not have.

I will go ahead with creating my general purpose style-sheet for the
site and then have a minimalist one for IE to have a peek at and sort
out any issues for IE 6.
--
Patrick
Brighton, UK

<http://www.patrickjames.me.uk>

Oct 25 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: neblackcat | last post by:
Would anyone like to comment on the following idea? I was just going to offer it as a new PEP until it was suggested that I post it here for comment & consideration against PEP 308. I'm far...
2
by: in | last post by:
In Visual Studio, is there a way of marking a statement as a "conditional run". Sort of like a breakpoint, but there, in the debugger, the statement will not execute. I'm thinking of code...
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...
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: ammarton | last post by:
Hello all...I'm a bit new to working with Macros in Access so forgive me if the terminology I use is not accurate. To preface this, basically I am using a form on a replicated database so the...
10
by: nimmi_srivastav | last post by:
Below you will see an example of a nested conditional expression that this colleague of mine loves. He claims that it is more efficient that a multi-level if-else-if structure. Moreover, our...
8
by: Typehigh | last post by:
I have many text fields with conditional formatting applied, specifically when the condition is "Field Has Focus". Without any events associated with the fields the conditional formatting works...
3
by: naunetr | last post by:
hello all, i wrote the small program below to practice conditional compiling. if i define MYSYMBOL then everthing works fine, but when i comment MYSYMBOL gcc gives the following message:...
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.