We've just installed Prism.js and got it working.

In this screencast we find a theme called the Tomorrow Theme and ingrate it's colors into the syntax highlighting. We make a little color key at the top of the file for quick reference. We also make some guesses as to what is what, at least to start. What we end up with, color wise, is OK but not spectacular. If you browse around the site today, you'll notice the color theme is more like Twilight, which I used to love in TextMate and I'm currently loving in Sublime Text 2.

We finish up by adding the header bars to code snippets. We don't have actual markup do this (which is probably good, it's mostly just a decorator) we add it through using a pseudo element and generated content via the rel attribute on the code. Most of the existing code on CSS-Tricks has this attribute. If it doesn't, not a big deal. We aren't really using rel in the correct way here, but I'm not overly worried about it.

pre[rel]:before {
  content: attr(rel);

We run into a little problem with making that pseudo element 100% wide with padding. Turns out our box-sizing declaration on the * selector doesn't affect pseudo elements (kinda makes sense), so we update our Normalize to include that.


  1. brendan
    Permalink to comment#

    Im pretty sure I read this on your blog… wasn’t the problem that the universal selector that you used to apply box sizing doesn’t apply to ::before and ::after unless you do *::before and *::after ??

Leave a Comment

Posting Code

We highly encourage you to post problematic HTML/CSS/JavaScript over on CodePen and include the link in your post. It's much easier to see, understand, and help with when you do that.

Markdown is supported, so you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences like this:

  function example() {
    element.innerHTML = "<div>code</div>";

We have a pretty good* newsletter.