
32 Javascript Alternatives with Pure CSS – Updated - janektm
http://speckyboy.com/2011/01/03/32-javascript-alternatives-with-pure-css-updated/
======
netghost
If anyone is curious about some other neat things you can do in css, I wrote
up a little article about drawing lines with it:
<http://monkeyandcrow.com/blog/drawing_lines_with_css3/>

I'll leave it as an exercise to the reader to come up with practical
applications ;)

------
romaniv
Interesting techniques, but some of these styles don't work on IE8, and some
are way too hackish. I really feel that there should be a way do a CSS
dropdown without using stuff like "text-indent:-9999px;".

------
RoyG
This is pretty interesting, but can someone please tell me the advantage of
using CSS instead of Javascript? Is it to reduce code cruft in each page, or
because some people turn Javascript off?

~~~
dgunn
While I haven't used many of the techniques described in the article, I would
imagine in many cases that using the CSS option would produce a smaller web
page. This is because all the elements you are modifying (in some way) with
JavaScript also are likely to have styles associated with them.

Also, if you're using jQuery (or some other framework) you necessarily add
several kB to the file size before you even write any code. While a single
style might be on the order of a few hundred bytes. Remember, bandwidth is
money and cutting down anywhere you can is important (just ask Google).

This won't hold true for all cases, but seeing these examples has already
cause me to think of several ways in which it would. Anyway, creativity loves
options! So it’s definitely worth reading.

~~~
mcdaid
This is only the case if the user has not got a cached version of jQuery,
which is likely if something like google's hosting service. In this case the
jQuery code may well be shorter than the css especially with all the browser
specific rules. In addition the jQuery version will work in all browsers.

~~~
dgunn
Good point. Especially about browser compatibility.

------
ez77
Are there security concerns related to enabling CSS?

~~~
rudasn
I am not about now but there were a few. Google css xss.

There was/is(?) the background-image on visited links "hack". Put simply, you
could specify a background-image on a link to, let's say, facebook.com and you
would know if the user has visited facebook because they would have loaded the
image.

I'm pretty sure today's browsers don't let you specify background images on
visited links because of this.

~~~
ez77
Thanks, that led me to
[http://scarybeastsecurity.blogspot.com/2009/12/generic-
cross...](http://scarybeastsecurity.blogspot.com/2009/12/generic-cross-
browser-cross-domain.html) .

