473,770 Members | 6,105 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A stylesheet for IE, another one for web browsers

Hi,

Once I was happy with my new deezign[1], I noticed how bad it breaks in IE
(all versions I tried). Since IE7[2] didn't give acceptable results, I
wrote a simplified style that I would fetch to IE. How to do it is the
point of my post.

I am using for now conditional comment[3] (clean) to give IE its CSS, and a IE
parsing bug[4] (not clean) to hide the real CSS from IE:

<!--[if IE]>
<link rel="stylesheet " type="text/css" href="site-IE.css">
<script src="navbar.js" type="text/javascript"></script>
<![endif]-->
<style type="text/css"><!-- @import url(site.css) all; --></style>

I am wondering whether a better method exists, especially one that would:
* not rely on a IE bug to hide the CSS file
* not break HTML validation (no <![if !IE]>...<![endif]>)
* provide good browsers with the two alternative stylesheets
* deal with several CSSes: all pages include (by SSI) site.css (or
site-IE.css), but some also include pro.css (resp. pro-IE.css), some
others perso.css (or perso-IE.css) (if I read the specs correctly,
<link rel="alternate stylesheet" ...> cannot fulfill this requirement)

A method that solves just one of the four points above would already be
great!

[1] http://yo.dan.free.fr/
[2] http://dean.edwards.name/IE7/
[3] http://msdn.microsoft.com/workshop/a...omment_ovw.asp
[4] http://www.phoenity.com/newtedge/hide_css_ie/

PS: I take this post as an opportunity to thank those who ansered my newbie
questions a while ago, and to thank everyone who intervenes in this forum:
you are definitely helping more than one person when you answer one
question! (I have been lurking for quite a while, as obviously many others
do.)

--
Daniel Déchelotte
http://yo.dan.free.fr/
Jul 21 '05
22 4966
Dave Anderson a écrit :

| Daniel Déchelotte wrote:
|
| > 1. <!--[if IE]>
| > 2. <![if !IE]>
| > 3. < -->
| > 4. <p>Read by browsers, ignored by IE
| > 5. <!-- >
| > 6. <![endif]>
| > 7. <![endif]-->
|
| I've never seen whatever information Microsoft provides about how
| "conditiona l comments" *should* work and I don't have IE here to test
| with but, assuming that this was implemented in some vaguely rational
| manner (which I admit is a big assumption), shouldn't this simple code
| work:
|
| <!--[if !IE]-->
| <p>read by browsers, ignored by IE
| <!--[endif]-->

Nope, and it breaks strangely, as IE displays everything, including the
comments! Well, as proprietary as they are, CCs follow a syntax, described
at the page I gave in my original post (reference [3]). ;-)

In an attempt to summarize the thread, the minimum code would be:

<!--[if IE]>
... IE specific code here ...
<![if !IE]>< -->
... non-IE code here ...
<!-- ><![endif]><![endif]-->

W3C and Microsoft compliant, if not terribly legible.

--
Daniel Déchelotte
http://yo.dan.free.fr/
Jul 21 '05 #11
On Wed, 12 Jan 2005 17:53:14 +0100, Daniel Déchelotte
<ma**********@f r.club-internet.invali d> wrote:
Dave Anderson a écrit : | Daniel Déchelotte wrote:
| ...shouldn't this simple code work:
|
| <!--[if !IE]-->
| <p>read by browsers, ignored by IE
| <!--[endif]--> Nope... [...]In an attempt to summarize the thread,
the minimum code would be:

<!--[if IE]>
... IE specific code here ...
<![if !IE]>< -->
... non-IE code here ...
<!-- ><![endif]><![endif]-->

W3C and Microsoft compliant, if not terribly legible.


Thanks for the investigation guys.

I'm saving this thread for a new entry in the ciwas authoring FAQ.

--
Rex
Jul 21 '05 #12
In message
<20************ *************** *******@fr.club-internet.invali d>, Daniel
Déchelotte <ma**********@f r.club-internet.invali d> writes
| >not rely on a IE bug to hide the CSS file


I don't know if it helps any, but I have set up a style sheet in php.

The .php script can sniff the browser and generate a style sheet that
differs in just the necessary ways.

(It can also propagate color/colour changes through the css, which si
why I did it).

You need to start it with...

<?php
header("Content-type: text/css");

and then go on to generate the rest, or it is not recognised by some
browsers.

Regards

Ian

--
Ian - posting to a Newsgroup. Please remove everything to reply.
Jul 21 '05 #13
Ian Hobson <Ne*******@ntlw orld.everything .com> wrote:
The .php script can sniff the browser


No it can't.

--
Spartanicus
Jul 21 '05 #14
Spartanicus <me@privacy.net > writes:
Ian Hobson <Ne*******@ntlw orld.everything .com> wrote:
The .php script can sniff the browser


No it can't.


Well, it can, but if it smells fish it can't know whether it
is fish.

--
Jón Fairbairn Jo***********@c l.cam.ac.uk

Jul 21 '05 #15
"Jón Fairbairn" <jo***********@ cl.cam.ac.uk> wrote:
>The .php script can sniff the browser


No it can't.


Well, it can, but if it smells fish it can't know whether it
is fish.


Then please tell me which browser I'm using:

+++GET 2+++
GET /TR/REC-CSS2/ HTTP/1.1
User-Agent: Code to W3C standards and stop that idiotic browser sniffing
(My OS; U) [en]

--
Spartanicus
Jul 21 '05 #16
On Mon, 17 Jan 2005, Spartanicus wrote:
"Jón Fairbairn" <jo***********@ cl.cam.ac.uk> wrote:
>The .php script can sniff the browser

No it can't.


Well, it can, but if it smells fish it can't know whether it
is fish.


Then please tell me which browser I'm using:

+++GET 2+++
GET /TR/REC-CSS2/ HTTP/1.1
User-Agent: Code to W3C standards and stop that idiotic browser sniffing
(My OS; U) [en]


Well, yes; but there are other considerations. And you *could* take
the view that if the client agent tells lies, then it deserves
whatever the server sends it.

Of course, the original statement would better have said something
like "the .php script can sniff what the client agent says it is, if
anything". But what conclusion do we draw from that observation?

The HTTP spec reminds us (see RFC2616 section 14.43) that this header
is optional, and could be used for statistical purposes (I've no
argument with that, as long as one understands its [un]reliability and
doesn't draw untenable conclusions from the results); for tracing of
protocol violations (yup), or for "tailoring responses to avoid
particular user agent limitations".

Now, this last is the one that I have a problem with, in the present
context. My *hunch* is that the RFC authors were thinking in terms of
modifying the *HTTP protocol response* to avoid certain user agent
limitations of HTTP support - you might recall stanzas of this kind in
Apache configurations:

SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0

But if, on the other hand, you're using this to vary not just the
protocol response but even the contents of the actual response body,
then you have a server-negotiated response body which varies according
to the user-agent string - thus, your negotiated response shall
include a "Vary: User-Agent" header, and this is very hostile to
cacheability. (Mark Nottingham's tutorial applies - not that I'd need
to tell -you- that!).

If, on the other hand, you send a carefully-designed *static*
response, which capitalises on some known shortcoming of the affected
browser, then you can be sure that it will have its intended effect no
matter what untruths the browser might tell in its user-agent string,
and *without* the slightest harmful effect on other users. Examples
of this general idea are the "hiding advanced CSS from browsers"
techniques discussed at
http://w3development.de/css/hide_css_from_browsers/

Then again, there's MSIE's conditional comments wibble, which - as
long as one confines oneself to the subset that is decent HTML syntax,
seems to me to be OK as a practice, even if the very idea can be rated
as pandering to something that's determined not to support published
interworking specifications.

So, in conclusion, my argument against server-varied response
documents depending on user-agent string are not merely that it's
unreliable in practice, but that it can cause degraded performance to
a wide range of users, with possibly serious degradation for those who
are behind a cache server proxy.
Jul 21 '05 #17
Spartanicus <me@privacy.net > writes:
"Jón Fairbairn" <jo***********@ cl.cam.ac.uk> wrote:
>The .php script can sniff the browser

No it can't.


Well, it can, but if it smells fish it can't know whether it
is fish.


Then please tell me which browser I'm using:

+++GET 2+++
GET /TR/REC-CSS2/ HTTP/1.1
User-Agent: Code to W3C standards and stop that idiotic browser sniffing
(My OS; U) [en]


Smells like fish to me. I've no idea whether it is fish though.

I think you missed the joke :-(

--
Jón Fairbairn Jo***********@c l.cam.ac.uk

Jul 21 '05 #18
"Alan J. Flavell" <fl*****@ph.gla .ac.uk> wrote:

[UA sniffing]
The HTTP spec reminds us (see RFC2616 section 14.43) that this header
is optional, and could be used for statistical purposes (I've no
argument with that, as long as one understands its [un]reliability and
doesn't draw untenable conclusions from the results); for tracing of
protocol violations (yup), or for "tailoring responses to avoid
particular user agent limitations".

Now, this last is the one that I have a problem with, in the present
context. My *hunch* is that the RFC authors were thinking in terms of
modifying the *HTTP protocol response* to avoid certain user agent
limitations of HTTP support


I know little about HTTP, but afaik HTTP protocol support of the UA
doesn't matter if the connection is via a proxy, only the proxy's HTTP
protocol support matters. Afaik proxies are not required or supposed to
alter the UA string, making UA sniffing for the purpose of avoiding
limitations in UA HTTP protocol support fundamentally flawed.

--
Spartanicus
Jul 21 '05 #19
"Jón Fairbairn" <jo***********@ cl.cam.ac.uk> wrote:
>> >The .php script can sniff the browser
>>
>> No it can't.
>
>Well, it can, but if it smells fish it can't know whether it
>is fish.


Then please tell me which browser I'm using:

+++GET 2+++
GET /TR/REC-CSS2/ HTTP/1.1
User-Agent: Code to W3C standards and stop that idiotic browser sniffing
(My OS; U) [en]


Smells like fish to me. I've no idea whether it is fish though.

I think you missed the joke :-(


Responses on usenet that are not supposed to be taken serious are best
delineated by adding an emoticon.

I read it as "you can find out the browser used, but it may not be
correct". This is not correct since as Alan pointed out the User-Agent
header is optional, and the string may not contain a reference to a UA
at all.

--
Spartanicus
Jul 21 '05 #20

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

Similar topics

8
2088
by: Ian Fitchet | last post by:
Hi, You'll excuse me if this has been answered before but I must have missed it on my travels: Is there a definitive style sheet with includes a definition for everything that a particular browser sets to not-null/zero/inherit? Given all the usual pixel adjustments here, browser specific bug
2
2823
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/authoring-faq Posting-Frequency: twice a week (Mondays and Thursdays) Last-modified: August 28, 2002 Version: 1.15 URL: http://css.nu/faq/ciwas-aFAQ.html Maintainer: Jan Roland Eriksson <rex@css.nu> ciwas stylesheet authoring FAQ v1.15 ______________________________________________________________________
12
3705
by: Tony Carnell | last post by:
Hi, Here's a conundrum that I hope someone out there can help me solve. I've created a page to XHTML 1.0 Transitional / CSS standards using Macromedia Dreamweaver MX 2004 (and validated both with no problems). Whilst creating the page I've previewed it in IE 6, FireFox 0.8 and Opera 7.21 on my PC and the page displays perfectly (well, as perfectly as IE's implementation of CSS will allow!)
12
2046
by: MasonC | last post by:
My site pages look ok in most browsers, including Safari on the Mac. With Mac's IE 5.2 the stylesheet is ignored. I've tried both @import and <Link. Any suggestions? Second question: assuming I don't want to add styles below the @import, is there any advantage in using it? How choose between @import and <Link ?? Mason C
3
4333
by: Jamie | last post by:
Hi, Thanks for the excellent answer to my last question! One more: Does anyone have a method they follow for organizing stylesheets themselves? They seem like they can get bloated and hard to read. Aside from putting all the "h1" rules together, I haven't thought of any way to do it, if it's necessary at all. J.
0
1960
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/authoring-faq Posting-Frequency: twice a week (Mondays and Thursdays) Last-modified: April 10, 2003 Version: 1.16 URL: http://css.nu/faq/ciwas-aFAQ.html Maintainer: Jan Roland Eriksson <rex@css.nu> ciwas stylesheet authoring FAQ v1.16 ______________________________________________________________________
7
2710
by: Vincent van Beveren | last post by:
Hi everyone I have a JavaScript app that creates an IFRAME through DOM (createElement('IFRAME')) However, that IFRAME does not have any content yet. alert(iframe.contentWindow.document.documentElement) gives null.
3
3305
by: gdelfino | last post by:
I have an XML file which I transform into XHTML using stylesheetA.xsl. I also have stylesheetB.xsl which transforms my XML file into an Excel XML document. As both Excel and most new browsers have a built in XSTL engine, I decided to add the stylesheet information to the original XML file. Like this <?xml version="1.0" encoding="utf-8" standalone="yes"?> <?xml-stylesheet href="stylesheetA.xsl" type="text/xsl" media="excel"?>
3
1874
by: Dave Angel | last post by:
I have implemented the 'A list apart' styleswitcher which works great. I now have: - A permanent stylesheet - A normal contrast stylesheet - A high contrast stylesheet The switcher simply switches between the normal/high sheets. HOWEVER. I now wish to add a font resizer. It needs to be able to
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10231
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10059
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7416
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6679
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.