Daily Tips & Tricks for Web Enthusiasts

Get new tips and tricks in your inbox every week!

You can also follow @CoreAssistance on Twitter (where I tweet about each day's tip), subscribe to the RSS feed, browse the archive, or start with the first tip.

Quickly Cycle Through Browser Tabs

In any web browser, on both Mac and Windows computers, hitting Control + Tab will take you to the next tab.

Want to go back? Control + Shift + Tab will take you to the previous tab.

Down for Everyone Or Just Me?

You visit a site, but it doesn’t load. Maybe it’s your website. Maybe it’s someone else’s. Doesn’t matter. The first thought that goes through your mind is the same:

Is this down for everyone, or just me?

Good news: There’s a website to answer that very question: Down for Everyone or Just Me. Just visit the site, provide the URL of the site in question, and you’ll get your answer.

They even have a shorter domain that’s easy to remember and easy to type: isup.me

Use Caution when Changing Default Outline Styles

Most web browsers apply a distinctive visual style to the element that’s currently in focus. This usually manifests as a prominent outline around the element, which is usually applied using the outline CSS property behind the scenes.

If the default outline style for focused elements clashes with your design you might be tempted to remove them using something like this:

:focus {
    outline: none;
}

Do not do this! Those default outline styles are there for a very important reason: accessibility. They help people who don’t (or can’t) use mice and people with visual impairments navigate your site. Removing the default outline styles without replacing them with something else will make your site harder to use for a lot of people.

Want to find out more? Good news! There’s an entire site dedicated to this issue, and it includes suggestions for alternative focus styles to use instead of the defaults: OutlineNone.com.

Embrace Curly Braces

In JavaScript (and many other C-style languages) you can do this:

if (condition)
    foo();

While this code is perfectly valid, and will run as expected, you should never omit an if statement’s curly braces like this. Why? Take a look at this code:

if (condition)
    foo();
    bar();

This code is also perfectly valid, but it’s incredibly deceptive. In this example, only foo(); is attached to the if statement. Despite appearances, bar(); will run no matter what.

This code is functionally identical, but much clearer:

if (condition) {
    foo();
}
bar();

Leaving out curly braces might save you a few keystrokes, but it’s a nightmare for code readability and maintenance. Save Future You from confusion and hassles: always use curly braces!

Smart Line Height

The line-height property has some unexpected inheritance behavior when used with a length or percentage. Take this CSS, for example:

div.example {
    font-size: 20px;
    line-height: 1.5em;
}

div.example h2 {
    font-size: 40px;
}

With this CSS you might expect the line height of h2 elements inside div.example elements to be 60px, but that’s not the case. No, with this CSS, everything inside div.example elements will get the same 30px of line height regardless of their own font size, including those h2 elements.

Why is this? When you provide a length or percentage value for the line-height property the line-height calculation is made at that point, and that calculated value is used going forward. The em unit specifies a length, so we get the 30px of line height calculated immediately and used everywhere.

The good news is that there’s an easy way around this problem: Never provide a length or percentage value when using line-height. Instead use a number with no unit, like this:

div.example {
    font-size: 20px;
    line-height: 1.5;
}

div.example h2 {
    font-size: 40px;
}

Now the line height will be calculated by multiplying the font size of whichever element the line height is being applied to. This results in 30px of line height inside div.example elements by default, and 60px of line height on the h2 elements inside them, just as expected.

Write Concisely

In a letter written in 1657, Blaise Pascal wrote the following:

I have made this longer than usual because I have not had time to make it shorter.

Blaise knew that a first draft is often a long, rambling affair that can be improved by putting in the time to tighten things up. Concise copy is often better copy, but why is it better? There are several reasons, many of which lead back to a simple truth: Clear and concise writing is respectful of the reader.

Shorter copy is more likely to keep your reader’s attention and saves them time. As your word count decreases, the likelihood that those words will all be read and thoughtfully considered increases. And, with fewer words, there are less places for boredom and repetition to hide.

Indeed, this week’s JavaScript tip began as a nine paragraph draft that didn’t work nearly as well as the five paragraphs I ended up publishing. It took a fair bit of work to trim it down, but (as my wife/proofreader will attest) it was worth the effort.

Perfection

Perfection works very well as a guiding light, but you should never expect to arrive there. The desire to attain perfection can be overwhelming, but it’s vital that you keep that temptation in check. As you get closer to perfection, the effort and time required to make meaningful progress rises exponentially. If you’re getting close to perfection, take it as a warning that you’re wasting time. The same resources required to bring a project from 90% to 95% can often bring a different project from 0% to 80%. Is that extra 5% really worth it?

It’s important to periodically take a step back from your work and ask yourself if what you’re working on is good enough. It can be painful to ship something that’s just good enough, especially when you know it has the potential to be better, but getting your work out the door is often the best course of action.

Keeping something to yourself while you futilely pursue perfection benefits no one. Releasing something that’s good enough helps the people you made it for, and it helps you. The reactions of others, once your work is set free, will give you clarity and perspective that you simply can’t get anywhere else.

Remember, good enough really is good enough.