“Muting” Pictures With Pure CSS

I’ve been somewhat wary about posting some of the images from some of the more extreme Fantagraphics comics I’ve written about (I’m thinking of you, Grit Bath).  Not everybody appreciates being flashed images of bitten-off ears or penises while scrolling down a blog.

On the other hand, I want to represent these comics honestly, so I thought it might be nice to “hide” images from more sensitive readers without making a big deal about it.  That is, I wanted them still to be accessible without the reader having to go to a new page, and I wanted to make this possible without adding a lot of redundant HTML to the articles.

Presto!

shot0028 png

The solution is pure CSS: I only have to add the “redact” class to the <a> link that surrounds the image.  It took me several hours of googling around to put all the pieces together, but the end result looks quite “d’oh, that’s simple”.  All the other solutions I found involved adding <div>s around and <p>s inside, which is yucky.

I’ve put the solution on Github for people interested in adapting it to their own needs.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s