Set Expires

Setting “expires” tells browsers downloading these files that they don’t need to request it again for this specific length of time. In otherwords, use the cache instead if you have it. This can reduce stress on the server for you, …

Avatar of Chris Coyier
Chris Coyier on

Grid Accordion with jQuery

Accordions are a UI pattern where you click on a title (in a vertical stack of titles) and a panel of content reveals itself below. Typically, all other open panels close when the new one opens. They are a clever …

Avatar of Chris Coyier
Chris Coyier on (Updated on )

Admin Panel Link Only For Admins

<?php if (current_user_can("manage_options")) : ?>
       <a href="<?php echo bloginfo("siteurl") ?>/wp-admin/">Admin</a>
<?php endif; ?>

If a user is logged in and they are an Admin of the site (not just an subscriber or author), then display a link to get them …

Avatar of Chris Coyier
Chris Coyier on

Drop Caps

The Accessible Way

Your best bet is to watch Ethan’s 5-minute video and then reference this:

CodePen Embed Fallback The cross-browser way (extra markup)

Just wrap the first character of the paragraph in a span, then target the span with …

Avatar of Chris Coyier
Chris Coyier on (Updated on )

Text Dripping Blood

.blood {
       color:silver;
       text-shadow:
       4px 4px 1px #300000,
       4px 6px 1px #400000,
       4px 8px 1px #500000,
       4px 10px 1px #600000,
       4px 12px 1px #700000,
       4px 14px 1px #800000,
       4px 16px 1px #900000,
       4px 18px 1px #A00000,
       4px 20px 1px #B00000,
       
Avatar of Chris Coyier
Chris Coyier on

Exclude $(this) from Selector

Let’s say you want to attach a click handler to every link on a page. The function for that click handler turns all the other links a different color.

var $allLinks = $("a");

$allLinks.click(function() {

     $allLinks.not(this).css("color", "red");

});

You can …

Avatar of Chris Coyier
Chris Coyier on

Fixing .load() in IE for cached images

The .load() function fires when the element it’s called upon is fully loaded. It is commonly used on images, which may not be fully loaded when the JavaScript originally runs, and thus would return incorrect information about themselves (e.g. height/width). …

Avatar of Chris Coyier
Chris Coyier on (Updated on )

List Posts, Highlight Current

WordPress lacks a wp_list_posts() function that might seem logical go with the robust and useful wp_list_pages() function. You can simulate it though, by using the get_posts() function and running your own loop through the results.

The parameters for get_posts() below …

Avatar of Chris Coyier
Chris Coyier on (Updated on )

What Changed?

If something was working, but now it’s broken, then something changed.


Many things are the same, some are different.

This is true with anything: your watch, a remote control, even your relationships. It’s certainly true with websites. If your website …

Avatar of Chris Coyier
Chris Coyier on