Latest Article

Using JavaScript to Style Active Navigation Elements

active navigation element

I’m all about efficiency when I’m writing web code. Any time I find myself writing the same functionality more than once or twice, I try to consider whether my repeated code could be wrapped into a function of some sort.

Navigation is often one of those areas where I try to improve my efficiency. I like my navigation elements to pull double duty. I want them to:

  1. Show the user where they can go, and
  2. Show the user where they currently are.

In other words, I want some sort of visual indication in my navigation that shows my user which section of my site they’re in. You can see this on the CSS Newbie site: if you click on the TOC (Table of Contents) link in the bar at the top of the page, you’ll see that link gets special styling when the table of content loads.

Now, I could manually set this on every page using a CSS class. But that’s inefficient — depending on the size of my site, I could end up writing dozens or hundreds of lines of one-off code. And why go to all that work, when you could just wrap it all up into a nice JavaScript function?

Read the full article here…

Reader Response: A Simple, Streamlined E-Commerce Solution

Today I come to you with my arms wide open — and my shoulders caught somewhere between a slump and a shrug. I’ve been tearing my hair out over the last couple of months looking for the perfect ecommerce solution. I’ve come up short.

A Simple jQuery Stylesheet Switcher

There are lots of reasons you might want to offer your users more than one CSS file for your website. But whatever the reason, it’s amazingly easy to create a function that swaps between multiple stylesheets using a few lines of jQuery.

15 Surefire Ways to Break Your CSS

When your CSS doesn’t behave the way it should, web design can be downright tedious. But some of the the biggest CSS blunders stem from the simplest of errors. Knowing what some of those errors are and remembering to look for them can save you hours of wasted labor.

New Poll: How Much CSS Do You Already Know?

I’ve posted a new poll in the footer of the website, and I’d appreciate if you’d take a second or two and answer the question: how much CSS do you already know? This is a chance for me to get to know you a little bit better. It will also help me to produce the sort of content that you would find most useful.