so i've just finished a book to learn CSS. (known HTML since high school but didn't have the initiative to pick up CSS 'til now).
anyways, ever since i started reading about pseudo-classes in CSS i always thought it was a:
- vast assortment of states for almost any tags. this would allow different formatting/layouting for any STATE of ANY ELEMENT. this would then be the mechanism to have pop-up/drop-down/tabbed menus/interactive buttons, controlling the INTERACTIVE look and feel of a page. this made sense, as CSS has always been aimed for formatting/layouting.
then i got to the end of the book and didn't find it. the most was the all-too-familiar using pseudo-classes, "hover", "visited", etc on to alter the formatting of the anchor element itself. http://www.w3schools.com/css/css_pseudo_classes.asp only lists a dozen pseudo-classes. so basically the rest of the elements needs to be handled by using onclick, onmouseover, etc, which are all javascript.
then i was dreaded with the notion that those interactive look and feel, even from popular and widely conforming websites, like youtube, facebook, google, etc, was achieved using javascript. i haven't gone through each of the said sites to see exactly how the code achieved those effects (it's gonna take me a while to decipher as i'm a novice in javascript; didn't even look at the .js files). but... it is JS, isn't it??
anyways, isn't it better if CSS does atleast most of the INTERACTIVE look and feel as i delineated in the point block above? implementing a drop-down navigation menu would then be like:
- if :hover is true for a button, then change the block formatting (as the button is actually a sinlge lined block). the children blocks would have their "display" style property turned on (previously hidden). they are then set on having a solid background color, padding, borders, etc.. now dispalyed, the user may interact with them like ordinary links.
the rest, mostly that requires information processing, will be through javascript.
i guess my biggest objection to implementing the interactive look and feel using JS is that you can't always fall reliably back on it.
- older and rarer browsers may full support of CSS but not JS.
- JS maybe disabled
- JS is usually slower (unless script is turned into binary and probably JIT-ed). this is more evident in mobile devices.