W3C home > Mailing lists > Public > www-style@w3.org > January 2003

Re: CSS comment hacks (was: small errors in the CSS2.1 grammar)

From: Vadim Plessky <lucy-ples@mtu-net.ru>
Date: Sat, 25 Jan 2003 17:34:34 +0300
To: James Craig <james@cookiecrook.com>, <www-style@w3.org>
Message-Id: <200301251734.34846.lucy-ples@mtu-net.ru>

On Friday 17 January 2003 01:23, James Craig wrote:
|  On 1/16/03 5:15 AM, "Lars Knoll" <lars@trolltech.com> wrote:
|  > Even here I think this is a bad idea. In javascript we've seen similar
|  > problems happen (this is from a real web page):
|  >
|  > if ( isNS ) {
|  > // do something
|  > } else if ( isIE ) {
|  > // different way of doing the same thing
|  > }
|  >
|  > Now guess what happened with konqueror (where isIE and isNS where both
|  > false). The site broke completely even though konqueror would have been
|  > able to correctly interpret both the NS and IE javascript sniplet. Using
|  > some sort of mechanism like the above one would make the same happen for
|  > CSS. Smaller browsers some web designer don't test for will break
|  > because they get unstyled contents.
|  Your example is flawed because the equivalent of what I was proposing
| would be more like (to continue the JavaScript analogy):
|  if(isIE) {
|    // do something
|  } else if(isNS4) {
|    // do something else
|  } else {
|    // do some something DOM-compliant that 'should' work in any browser
|  }

Your example, is wrong, as default branch is usually left for 
non-DOM-compliant browsers (Opera, Lynx, old Netscape Navigator 4.7, etc.)
So, suggestion that Konqueror or Safari  (both are KHTML-based) should go into 
"default" branch is wrong and non-acceptable for me.

Correct segemtn fo code should be something like this:

if(isDOM) {
  // DOM-specific code
} else if(isIE4up) {
  // IE4 specific code
} else if (isNN4) {
  // NN 4.x specific code
  // code for non-DOM, non-DHTML browsers, should work in any browser

And you just demonstrated that web designers *can't* write good enough code.

So, I strongly back proposal that web authors should write W3C-compliant code, 
without hacks for "this, this and this" browser.
And good CSS code is one of the ways to achieve this goal.

|  But it's still not quite the same. I'll continue.
|  Later,
|  James
|  PS. I used the MacIE5 hack merely as an example. I could have used some
|  other hack on a different browser and I'm making no claims as the the
|  'superiority' of one browser or parser versus another.

BTW: if you need "portable" solution to distribute some corporate web-based 
application inside a company, you should make one browser the standard in 
your company, and write code specific to that browser only.
Than you would avoid compatibility problems.
Another solution could be to use Netscape7/Mozilla in mixed environment 
(supposing that you need browser on Windows platform, too), and write 
DOM-based, CSS-based code only.


Vadim Plessky
SVG Icons * BlueSphere Icons 0.3.0 released
My KDE page
http://kde2.newmail.ru  (English)
KDE mini-Themes
Received on Saturday, 25 January 2003 09:50:11 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:05 UTC