Forum Moderators: phranque

Message Too Old, No Replies

Why CSS and not JavaScript?

CSS vs JavaScript

         

MarcMiller

7:50 pm on Apr 22, 2006 (gmt 0)

10+ Year Member



Hi
I recently visited this site where I picked up some very good CSS tips. In this site the author of these tips states "I try to keep pure and avoid JavaScript". And all over the Web I see sites that tout the virtues of pure CSS. So my question is why. Do most of you think CSS is better than JavaScript, why and when is it better than JavaScript. I am trying to learn things well but I need some guidance in this regard.
Sincerely
Marc

abbeyvet

8:13 pm on Apr 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It is not really an either/or situation, CSS and Javasript do completely different jobs. CSS is for presentation and style, JavaScript is for function.

I think what you may be reading about are things that can be accomplished with CSS without the need for Javascript, where in the past Javascript was commonly used, for example image swaps in navigation and mouseovers and that sort of thing.

In those cases CSS is more efficient. But the number of things that can done by either, ie where you can choose which to use, is tiny, and CSS is certainly not a replacement for Javascript in any sense at all.

Avoiding what might be called 'gratuitous' Javascript is always a good idea, especially since quite a surprinsing number of people seem to browse with Javascript disabled. But getting obsessive about avoiding it isn't necessarily the way to go - use whatever works best in any situation, and sometimes, that is Javascript.