GreatWebGuy Self-proclaimed greatness is a hard thing to prove.

1May/091

Writing JavaScript specific CSS

I wrote an article recently recommending Using jQuery to write JavaScript specific CSS, I've since change my mind on this approach. The approach I've moved to is similar, but doesn't rely on a framework and allows more flexibility like moving all of my JavaScript includes to the bottom of the page for better performance.

In your html template or page add a nojs class to your html node and a script tag in the head section below your title changing the className to js:

<html class="nojs">
<head>
<title>My Title</title>
<script>document.documentElement.className = "js";</script>

Now you can write CSS like this:

.nojs a.myclass {color:red}
.js a.myclass {color:black}
a.myclass2 {color:blue}

In this very simple example all of your non-javascript users would see links with a class of myclass as red and all javascript enabled users would see the links with the color black. Both javascript and non-javascript users would see the links with the class myclass2 as blue.

This very simple example opens hundreds of possibilities for the way you style your site. You could actually display and hide content based on whether javascript is enabled or not, including buttons and links or any element on the page. You could include text for Search Engines and Screen Readers that your regular users might not need to see because the nature of the content could be for SEO or descriptive purposes for non-javascript users. You could also use it to enhance your suckerfish CSS menus with a hoverIntent when javascript is enabled making your menus a little more user friendly.

This is an improvement on the previous method I used because it doesn't depend on a JavaScript framework, it allows you to put off loading all of your JavaScript until the bottom of the page, improving performance, and allows you to utilize CSS to hide, disable, or fade in elements of the page that you don't want to be displayed until the document has been loaded and is ready to perform all that RIA functionality you've added to your app.

Tagged as: , 1 Comment
18Mar/072

15 Great Resources for Up and Coming CSS Designers

Working at a corporation with a bunch of stuffy Java Developers it seems like there's a resistance against using purely CSS for layout, decoration, and design. These Java Developers love their tables and don't want to let them go. Recently we hired two CSS designers, all they think do and breath is CSS, which was a big step in the right direction by our management. Since the Java Developers are now being mandated to embrace CSS, thanks to me sharing CSS Zen Garden with someone in upper management, maybe it's time to study up. The following list of sites come highly recommended from our top CSS designer, enjoy!

Tagged as: Continue reading