`](/2010/10/your-logo-is-an-image-not-a-h1/) and is in fact an image (` `) in its own right. Now let’s cover some nice little tips and snippets for making the most of your markup and creating a nicer UX around it.
The techniques I’m going to cover can be found on my recently launched hub site [hry.rbrts.me](http://hry.rbrts.me), but for the sake of clarity I have [isolated them in a jsFiddle here](http://jsfiddle.net/csswizardry/h7zrY/).
diff --git a/_posts/2011-08-08-updated-cv.markdown b/_posts/2011-08-08-updated-cv.markdown
index 1fe37514..9361eb87 100644
--- a/_posts/2011-08-08-updated-cv.markdown
+++ b/_posts/2011-08-08-updated-cv.markdown
@@ -37,7 +37,7 @@ Initially I actually just wrote everything out in one giant `` with `
So far in I thought that that seemed a little too easy/lazy, and it also came with the massive issue of not being semantic, meaningful or just plain proper markup. A CV is a series of headings and lists, not a single block of preformatted text.
-I got to work rewriting, refactoring and tidying and marked it all up properly, and moved any braces, comments and quotes etc out of the HTML and into the CSS making [massive use of the `content:;` property](http://csswizardry.com/2010/09/keeping-code-clean-with-content/).
+I got to work rewriting, refactoring and tidying and marked it all up properly, and moved any braces, comments and quotes etc out of the HTML and into the CSS making [massive use of the `content:;` property](/2010/09/keeping-code-clean-with-content/).
The resulting document is a semantically sound, properly marked up CV that is transformed into a CSSesque appearance using, well, CSS.
diff --git a/_posts/2011-08-18-good-developers-are-illusionists.markdown b/_posts/2011-08-18-good-developers-are-illusionists.markdown
index 01e8903d..e59a1696 100644
--- a/_posts/2011-08-18-good-developers-are-illusionists.markdown
+++ b/_posts/2011-08-18-good-developers-are-illusionists.markdown
@@ -30,7 +30,7 @@ Another practical example of this is something I helped someone out with recentl
-
+
@@ -54,7 +54,7 @@ Enter the magic of illusion. Here's how I tackled that problem:
-
+
diff --git a/_posts/2011-09-11-when-using-ids-can-be-a-pain-in-the-class.md b/_posts/2011-09-11-when-using-ids-can-be-a-pain-in-the-class.md
index 05abc28e..0174779b 100644
--- a/_posts/2011-09-11-when-using-ids-can-be-a-pain-in-the-class.md
+++ b/_posts/2011-09-11-when-using-ids-can-be-a-pain-in-the-class.md
@@ -66,7 +66,7 @@ I did mention that you can add a class as well as the ID or remove the ID comple
### Remove IDs completely?
-We’ve covered where IDs can trip us up and be but they serve a purpose other than style-hooks; they can be used as [fragment identifiers](http://csswizardry.com/2011/06/namespacing-fragment-identifiers/) for marking landmarks in the page.
+We’ve covered where IDs can trip us up and be but they serve a purpose other than style-hooks; they can be used as [fragment identifiers](/2011/06/namespacing-fragment-identifiers/) for marking landmarks in the page.
I’m sure you’ve seen ‘Skip to navigation’ or ‘Jump to content’ links in pages, and these wouldn’t work without our IDs so we need to keep those in as well as adding our new class.
diff --git a/_posts/2011-09-17-writing-efficient-css-selectors.md b/_posts/2011-09-17-writing-efficient-css-selectors.md
index e9d0638b..dfee67ca 100644
--- a/_posts/2011-09-17-writing-efficient-css-selectors.md
+++ b/_posts/2011-09-17-writing-efficient-css-selectors.md
@@ -5,6 +5,7 @@ layout: post
slug: writing-efficient-css-selectors
title: Writing efficient CSS selectors
wordpress_id: 3144_
+meta: "CSS selectors, and their combinations, can be fast or slow! And while hopefully imperceptible, it’s definitely worth knowing about."
categories:
- Web Development
tag:
@@ -13,7 +14,7 @@ tag:
- Performance
---
-Efficient CSS is not a new topic, nor one that I really need to cover, but it’s something I’m really interested in and have been keeping an eye on more and more since working at [Sky](http://csswizardry.com/case-studies/bskyb/).
+Efficient CSS is not a new topic, nor one that I really need to cover, but it’s something I’m really interested in and have been keeping an eye on more and more since working at [Sky](/case-studies/bskyb/).
A lot of people forget, or simply don’t realise, that CSS can be both performant and non-performant. This can be easily forgiven however when you realise just how little you can, err, realise, non-performant CSS.
diff --git a/_posts/2011-10-16-the-island-object.md b/_posts/2011-10-16-the-island-object.md
index f344071a..a0b2c092 100644
--- a/_posts/2011-10-16-the-island-object.md
+++ b/_posts/2011-10-16-the-island-object.md
@@ -17,7 +17,7 @@ tag:
One thing I’ve been doing a lot of lately, since starting at [Sky](http://sky.com/), is writing abstractions. [OOCSS](http://www.oocss.org) is nothing new, but its basic premise is that you can build really simple objects using a base class and then extend that object with more classes to add more styling to make a simple construct progressively more complex and specific.
-One abstraction I love is by [Nicole Sullivan](https://twitter.com/stubbornella) (one of the best front-end devs in the world ever); the [media object](http://www.stubbornella.org/content/2010/06/25/the-media-object-saves-hundreds-of-lines-of-code/). Another I wrote is the more simple [nav abstraction](http://csswizardry.com/2011/09/the-nav-abstraction/).
+One abstraction I love is by [Nicole Sullivan](https://twitter.com/stubbornella) (one of the best front-end devs in the world ever); the [media object](http://www.stubbornella.org/content/2010/06/25/the-media-object-saves-hundreds-of-lines-of-code/). Another I wrote is the more simple [nav abstraction](/2011/09/the-nav-abstraction/).
Today I’m going to share one that’s simpler still; the _island object_...
diff --git a/_posts/2011-10-18-reset-restarted.md b/_posts/2011-10-18-reset-restarted.md
index 385857d7..79a51f13 100644
--- a/_posts/2011-10-18-reset-restarted.md
+++ b/_posts/2011-10-18-reset-restarted.md
@@ -150,13 +150,13 @@ Things I’ve removed:
* Aforementioned lists reset.
* Removal of borders from fieldsets (this needs defining on a per-design basis).
* Font weights and styles have been redefined rather than removed.
-* Removed the underlines from the redefined `u` element as well as from the `a` by default as per my article [On negative hovers](http://csswizardry.com/2011/05/on-negative-hovers/).
+* Removed the underlines from the redefined `u` element as well as from the `a` by default as per my article [On negative hovers](/2011/05/on-negative-hovers/).
Things I’ve added:
* Default stylings for text-level elements.
* Default styles for several new and/or redefined HTML5 elements (e.g. `mark` and `u`).
-* [Text styles on images](http://csswizardry.com/2011/06/styling-alt-text-on-images/)
+* [Text styles on images](/2011/06/styling-alt-text-on-images/)
* Make form elements inherit type properly.
Even if you don’t choose to use my reset (though it’d be great if you did) the one thing I urge you to take from this article is **think about your reset**. If you find yourself constantly overwriting rules from it then you ought to remove them. And remember; your reset can change per-build! You don’t always have to use the same one, just alter it where necessary for each design.
diff --git a/_posts/2011-10-25-build-along-testing-the-water.md b/_posts/2011-10-25-build-along-testing-the-water.md
index be9e7728..42ceb00c 100644
--- a/_posts/2011-10-25-build-along-testing-the-water.md
+++ b/_posts/2011-10-25-build-along-testing-the-water.md
@@ -13,11 +13,11 @@ tag:
- HTML
---
-**N.B.** The build along [went ahead](http://csswizardry.com/2011/11/build-along-1-reflection-and-reasoning/).
+**N.B.** The build along [went ahead](/2011/11/build-along-1-reflection-and-reasoning/).
I’ve been toying around with this idea the last few weeks. I’ve decided to do a quick _testing-the-water_ blog post to gauge interest and see whether anyone else would be into the idea. The story goes thus...
-A few weeks ago I was building a page for my good friend and awesome chap [Nick Payne](http://twitter.com/makeusabrew)--the page had been designed by another swell fella, [Ian Thomas](http://twitter.com/anatomic). We’re all pretty good friends and all excel in different areas, Ian designed Nick’s site and, [as designers _don’t_ need to code](http://csswizardry.com/2011/09/do-designers-need-to-code/), I built it. Nick sorted all the back-end and is building it onto [JAOSS](http://jaoss.org).
+A few weeks ago I was building a page for my good friend and awesome chap [Nick Payne](http://twitter.com/makeusabrew)--the page had been designed by another swell fella, [Ian Thomas](http://twitter.com/anatomic). We’re all pretty good friends and all excel in different areas, Ian designed Nick’s site and, [as designers _don’t_ need to code](/2011/09/do-designers-need-to-code/), I built it. Nick sorted all the back-end and is building it onto [JAOSS](http://jaoss.org).
**N.B.** Ian can and does actually code, but for this project we all wanted a slice of the action so, in this case, he didn’t...
diff --git a/_posts/2011-10-27-the-css-wizardry-build-along-is-go.markdown b/_posts/2011-10-27-the-css-wizardry-build-along-is-go.markdown
index 50bf3c4d..4f1a8138 100644
--- a/_posts/2011-10-27-the-css-wizardry-build-along-is-go.markdown
+++ b/_posts/2011-10-27-the-css-wizardry-build-along-is-go.markdown
@@ -13,7 +13,7 @@ tag:
- HTML
---
-Okay, so you decided it wouldn't be boring and that I'm not big-headed in thinking that people might actually want to watch me coding, so I'm quite excited to announce that [the build-along](http://csswizardry.com/2011/10/build-along-testing-the-water/) will be going ahead!
+Okay, so you decided it wouldn't be boring and that I'm not big-headed in thinking that people might actually want to watch me coding, so I'm quite excited to announce that [the build-along](/2011/10/build-along-testing-the-water/) will be going ahead!
diff --git a/_posts/2011-10-31-fully-fluid-responsive-css-carousel.md b/_posts/2011-10-31-fully-fluid-responsive-css-carousel.md
index 2de1ae83..62f546ad 100644
--- a/_posts/2011-10-31-fully-fluid-responsive-css-carousel.md
+++ b/_posts/2011-10-31-fully-fluid-responsive-css-carousel.md
@@ -195,7 +195,7 @@ The problem is that you have to know how many full moves and pauses are needed f
## Update
-Massive thanks to Clay who’s worked out that the number of steps is 4n-3 and that the total time between start of one animation and the next is 100 / 2(n-1) (where n is the number of panes). See [his full comment](http://csswizardry.com/2011/10/fully-fluid-responsive-css-carousel/#comment-95396).
+Massive thanks to Clay who’s worked out that the number of steps is 4n-3 and that the total time between start of one animation and the next is 100 / 2(n-1) (where n is the number of panes). See [his full comment](/2011/10/fully-fluid-responsive-css-carousel/#comment-95396).
But, the code above will sort you out a perfect animation for a five panes so feel free to nab it! I’ll update if and when I crack some maths!
diff --git a/_posts/2011-11-02-sam-penrose-design-process-and-write-up.md b/_posts/2011-11-02-sam-penrose-design-process-and-write-up.md
index 50245571..d7a8b1a0 100644
--- a/_posts/2011-11-02-sam-penrose-design-process-and-write-up.md
+++ b/_posts/2011-11-02-sam-penrose-design-process-and-write-up.md
@@ -35,7 +35,7 @@ I’ll touch on each of these in a little more detail.
Basic really; this site uses loads of gradients, round corners, shadows, all that stuff. None of it works in IE_x_ but that’s cool. Sites don’t have to look the same in every browser (and we took that to a bit of an extreme where media queries are concerned).
-It uses my [fluid carousel](csswizardry.com/2011/10/fully-fluid-responsive-css-carousel/) which doesn’t even behave like a carousel in IE, it acts as more of a promo. This is fine, though, as we were careful to only put non-essential content in here. Got a good browser? You get a pure CSS carousel. Got an older one? You get what looks like a nice, fluid promo panel.
+It uses my [fluid carousel](/2011/10/fully-fluid-responsive-css-carousel/) which doesn’t even behave like a carousel in IE, it acts as more of a promo. This is fine, though, as we were careful to only put non-essential content in here. Got a good browser? You get a pure CSS carousel. Got an older one? You get what looks like a nice, fluid promo panel.
## Content-out
diff --git a/_posts/2011-11-05-build-along-1-reflection-and-reasoning.md b/_posts/2011-11-05-build-along-1-reflection-and-reasoning.md
index dff17d42..832adf6b 100644
--- a/_posts/2011-11-05-build-along-1-reflection-and-reasoning.md
+++ b/_posts/2011-11-05-build-along-1-reflection-and-reasoning.md
@@ -17,7 +17,7 @@ tag:
- Responsive web design
---
-Here are, in no particular order, just a few thoughts about [the build-along](http://csswizardry.com/2011/11/css-wizardry-build-along-1/) I did last night. These thoughts cover the thinking and reasoning behind the decisions I made. The build-along was a single, small PSD, but the following should apply to builds of any size. Get into the habit of doing the following on tiny sites and you’ll be well equipped to build that next Facebook meets YouTube with a dash of LinkedIn that that prospective client just emailed you about...
+Here are, in no particular order, just a few thoughts about [the build-along](/2011/11/css-wizardry-build-along-1/) I did last night. These thoughts cover the thinking and reasoning behind the decisions I made. The build-along was a single, small PSD, but the following should apply to builds of any size. Get into the habit of doing the following on tiny sites and you’ll be well equipped to build that next Facebook meets YouTube with a dash of LinkedIn that that prospective client just emailed you about...
Here is [the final build](http://dl.dropbox.com/u/2629908/build-along/index.html) and its code is on [GitHub](https://github.com/csswizardry/build-along-1).
@@ -27,7 +27,7 @@ I built this HTML-first. No CSS other than the UA’s _whatsoever_. No images, n
## No IDs
-The build uses no IDs for styling. This was quite an odd shift for me to make, and I made it [a number of weeks back](http://csswizardry.com/2011/09/when-using-ids-can-be-a-pain-in-the-class/). The main drawback of using IDs is that they introduce a specificity wild card not unlike using `!important` (though obviously not as horrible). By not using them it means that I can’t really get tripped up by overly specific selectors as easily as I could if I _was_ using IDs. I’ve not removed the chance completely, but really easily and quickly lessened it.
+The build uses no IDs for styling. This was quite an odd shift for me to make, and I made it [a number of weeks back](/2011/09/when-using-ids-can-be-a-pain-in-the-class/). The main drawback of using IDs is that they introduce a specificity wild card not unlike using `!important` (though obviously not as horrible). By not using them it means that I can’t really get tripped up by overly specific selectors as easily as I could if I _was_ using IDs. I’ve not removed the chance completely, but really easily and quickly lessened it.
## ‘Ugly’ classes to do lots of heavy lifting
@@ -87,7 +87,7 @@ Here’s a challenge, next time your designer sends you a PSD designed on, say,
## Be resourceful
-During this build I copied and pasted _loads_ of code. I used [my vanilla boilerplate](https://github.com/csswizardry/vanilla), I copied and pasted [the media object](http://www.stubbornella.org/content/2010/06/25/the-media-object-saves-hundreds-of-lines-of-code/), [the nav abstraction](csswizardry.com/2011/09/the-nav-abstraction/), [the carousel](csswizardry.com/2011/10/fully-fluid-responsive-css-carousel/). If it already exists somewhere then reuse it! There are no prizes for writing more lines of code; be resourceful.
+During this build I copied and pasted _loads_ of code. I used [my vanilla boilerplate](https://github.com/csswizardry/vanilla), I copied and pasted [the media object](http://www.stubbornella.org/content/2010/06/25/the-media-object-saves-hundreds-of-lines-of-code/), [the nav abstraction](/2011/09/the-nav-abstraction/), [the carousel](/2011/10/fully-fluid-responsive-css-carousel/). If it already exists somewhere then reuse it! There are no prizes for writing more lines of code; be resourceful.
## Take away?
diff --git a/_posts/2011-12-07-measuring-and-sizing-uis-2011-style.md b/_posts/2011-12-07-measuring-and-sizing-uis-2011-style.md
index a60f64ad..1d4e69e9 100644
--- a/_posts/2011-12-07-measuring-and-sizing-uis-2011-style.md
+++ b/_posts/2011-12-07-measuring-and-sizing-uis-2011-style.md
@@ -22,7 +22,7 @@ These methods seem to have all happened sequentially, with us each time dropping
Let’s forget responsive design for a second. Responsive design is a three-tiered approach but here we’re only interested in fluid layouts (N.B. not even necessarily fluid grids). A fluid layout, as you all know, is one that is size-agnostic; it acts like a liquid, occupying a constant percentage of a varying space.
-Now, fluid grids are a little tricky as they’re based around full grid systems. Luckily I’ve created a simple [fluid grid calculator](http://csswizardry.com/fluid-grids/) to work these behemoths out, but in more simple terms it’s remarkably easy to set a fluid layout even if that was never the intention.
+Now, fluid grids are a little tricky as they’re based around full grid systems. Luckily I’ve created a simple [fluid grid calculator](/fluid-grids/) to work these behemoths out, but in more simple terms it’s remarkably easy to set a fluid layout even if that was never the intention.
If your designer sends you a two-column design then all you need to do is work out **not** how big the respective columns are, but instead work out _how much bigger one is than the other_. That is to say; stop thinking ‘this content area is 600px and the sidebar is 300px’ and _start_ thinking ‘this content area is twice as big as the sidebar’. Percentages work well whether you’re going responsive or not!
@@ -70,7 +70,7 @@ To work out unitless line-heights is simple. Use the following equation: the lin
## Using rems
-Despite [my initial thoughts](http://csswizardry.com/2011/05/font-sizing-with-rem-could-be-avoided/), I have now started setting type in rems (with a pixel fallback).
+Despite [my initial thoughts](/2011/05/font-sizing-with-rem-could-be-avoided/), I have now started setting type in rems (with a pixel fallback).
This gives us two things, firstly we have what I call ‘progressive accessibility’ in that it brings the accessibility benefits of ems but only in more advanced browsers.
diff --git a/_posts/2012-02-29-pragmatic-practical-font-sizing-in-css.md b/_posts/2012-02-29-pragmatic-practical-font-sizing-in-css.md
index f4e2936c..34ff47ab 100644
--- a/_posts/2012-02-29-pragmatic-practical-font-sizing-in-css.md
+++ b/_posts/2012-02-29-pragmatic-practical-font-sizing-in-css.md
@@ -160,7 +160,7 @@ Okay, so far we’ve worked with body copy to headings to beyond; what about sma
small,.omega.milli { [font styles] }
-[`small` has been redefined in HTML5](http://csswizardry.com/2011/01/html5-and-text-level-semantics/#small-el) so that’s an element we can use again freely and `.omega` is simply the last letter in the Greek alphabet.
+[`small` has been redefined in HTML5](/2011/01/html5-and-text-level-semantics/#small-el) so that’s an element we can use again freely and `.omega` is simply the last letter in the Greek alphabet.
#### Addendum
diff --git a/_posts/2012-03-13-hacker-news-rebuttal.md b/_posts/2012-03-13-hacker-news-rebuttal.md
index e078ea1c..ed2c9cc0 100644
--- a/_posts/2012-03-13-hacker-news-rebuttal.md
+++ b/_posts/2012-03-13-hacker-news-rebuttal.md
@@ -165,7 +165,7 @@ I’m pretty sure no CSS developer has ever said ‘I wish I’d used an ID here
IDs work, sure, but they are way too specific. It doesn’t matter how good a developer you are, you cannot change the fact that an ID is massively more specific than a class.
-I would genuinely love to see an elegant solution to [this](http://jsfiddle.net/csswizardry/3sxZR/) that doesn’t use a class over an ID. ([There isn’t one.](http://csswizardry.com/2011/09/when-using-ids-can-be-a-pain-in-the-class/))
+I would genuinely love to see an elegant solution to [this](http://jsfiddle.net/csswizardry/3sxZR/) that doesn’t use a class over an ID. ([There isn’t one.](/2011/09/when-using-ids-can-be-a-pain-in-the-class/))
There is literally _no_ reason why, from a purely CSS point of view, that an ID is better than a class. An ID is impossible to reuse (whether you want to or not) and they have a way-over-the-top specificity.
diff --git a/_posts/2012-04-17-introducing-faavorite.md b/_posts/2012-04-17-introducing-faavorite.md
deleted file mode 100644
index 8e695e3f..00000000
--- a/_posts/2012-04-17-introducing-faavorite.md
+++ /dev/null
@@ -1,36 +0,0 @@
----
-comments: true
-date: 2012-04-17 21:25:51
-layout: post
-slug: introducing-faavorite
-title: Introducing faavorite
-wordpress_id: 3553
-categories:
-- faavorite
----
-
-Okay, I say ‘introducing’, but it’s been live for almost a month now!
-
-Me and one of my bestest friends and most-talented-developers-ever [Nick Payne](http://twitter.com/makeusabrew) have been working since the beginning of 2012 on my faavorite project to date: [faavorite](http://faavorite.com).
-
-faavorite is, at its heart, [a tool for managing your Twitter favorites. You can tag, search, discuss, consume, read, share (and a lot, lot more) yours and others’ Twitter favorites](http://faavorite.com) from right within the app. We’ve put your favorites to work **big time**.
-
-We all know how favorites work; you see a funny tweet, something you want to read later, a great code tip or just something that made you smile, and you favorite it. Whilst the intention is good, how often do you head back to your favorites? Twitter don’t really do anything of use with them; you can’t search them, you can sort or categorise them, you can’t _really_ do anything with them…
-
-This is a problem Nick and I really seemed agreed on, and we both wanted to solve it. And, over a few months, that’s what we did, and what we’re still doing.
-
-I aim to do at least one technical post about faavorite pretty soon detailing the mobile-first, OOCSS, designed-in-the-browser, no-IE7-support approach. I want to document the front-end architecture and a few new things in quite a lot of detail but with 101 things on at the moment that will have to wait.
-
-For now I’d like to thank:
-
-* **[Nick](http://twitter.com/makeusabrew)**, for just being superawesome. He’s worn many hats throughout this project, including—but not limited to—developer, DevOps, SysAdmin, hotelier, barista and a whole host more. You can read [his impressive and mind-boggling technical writeup](http://paynedigital.com/2012/04/faavorite-tech-stack) of the app at your own risk will.
-* **[Lucy](http://twitter.com/lucybest)**, Nick’s girlfriend, for putting up with me seeing Nick more than she now gets to, and for cooking up some ace meals during our full-weekend coding sessions.
-* **[Bryan James](http://twitter.com/WengersToyBus)**, the guy who created the faavorite brand. It’s a thing of beauty, I’m sure you’ll agree.
-* **You guys!** The users, the people who’ve given feedback and suggestions and who’ve generally made the project worthwhile.
-
-If you’ve not signed up already but use Twitter then I encourage you to give it a whirl; it’s free and, well, I think it’s pretty awesome: [faavorite.com](http://faavorite.com)
-
-Oh and one other thing; if you’re already in (and like) faavorite, please consider inviting your friends along. Content is better shared and the more the merrier. We really need to get some non-web-geeks in faavorite as soon as possible in order to diversify (and not seem like an app just for web dev types) so if you have any friends on Twitter who might be interested then please do send them our way! Happy faavoriting!
-
-Cheers,
-_H_
diff --git a/_posts/2012-04-20-my-html-css-coding-style.md b/_posts/2012-04-20-my-html-css-coding-style.md
index 3ac793f1..48fac9a8 100644
--- a/_posts/2012-04-20-my-html-css-coding-style.md
+++ b/_posts/2012-04-20-my-html-css-coding-style.md
@@ -113,7 +113,7 @@ This is certainly not uncommon practice, but because all closing tags look the s
### Namespaced fragment identifiers
-I came up with [this idea to namespace fragment identifiers](http://csswizardry.com/2011/06/namespacing-fragment-identifiers/) last year. It’s basically, I think, a nice way to add a little more meaning to your fragment identifiers and give a little bit more of a clue as to what they actually link to.
+I came up with [this idea to namespace fragment identifiers](/2011/06/namespacing-fragment-identifiers/) last year. It’s basically, I think, a nice way to add a little more meaning to your fragment identifiers and give a little bit more of a clue as to what they actually link to.
Fragment identifiers
@@ -129,7 +129,7 @@ So far I’ve dealt with how I write HTML, but what about CSS? My CSS is a lot l
### No IDs
-This is more a technical thing, but I have [a blanket-ban on IDs in CSS](http://csswizardry.com/2011/09/when-using-ids-can-be-a-pain-in-the-class/). There is literally no point in them, and they only ever cause harm. Everything that needs styling is done so without using IDs.
+This is more a technical thing, but I have [a blanket-ban on IDs in CSS](/2011/09/when-using-ids-can-be-a-pain-in-the-class/). There is literally no point in them, and they only ever cause harm. Everything that needs styling is done so without using IDs.
### Table of contents
diff --git a/_posts/2012-05-15-keep-your-css-selectors-short.md b/_posts/2012-05-15-keep-your-css-selectors-short.md
index 42453310..5b2e88c0 100644
--- a/_posts/2012-05-15-keep-your-css-selectors-short.md
+++ b/_posts/2012-05-15-keep-your-css-selectors-short.md
@@ -30,92 +30,92 @@ Keeping CSS selectors short helps with a lot of things:
This is a very vague list, so I’m going to address each in order. You will find that there is a lot of crossover between each point (e.g. reducing location dependency inherently means your selectors are more portable) but I feel they are all points in their own right.
-## Increases selector efficiency
+## Increases Selector Efficiency
-I have written before about CSS selector efficiency. I’m going to gloss over a lot of the intricacies in this post so for a full background understanding I recommend you read [Writing efficient CSS selectors](http://csswizardry.com/2011/09/writing-efficient-css-selectors/) first.
+I have written before about CSS selector efficiency. I’m going to gloss over a lot of the intricacies in this post so for a full background understanding I recommend you read [Writing efficient CSS selectors](/2011/09/writing-efficient-css-selectors/) first.
-If we ignore actual types of selector (`*{}` is typically the slowest, depending on how it’s being used, IDs are the fastest followed by classes, descendants are comparably quite slow followed by pseudo-selectors) then _in general_ it is safe to say that shorter selectors are faster.
+If we ignore actual types of selector (`* {}` is typically the slowest, depending on how it’s being used, IDs are the fastest followed by classes, descendants are comparably quite slow followed by pseudo-selectors) then _in general_ it is safe to say that shorter selectors are faster.
This stands to reason, if we compare these two selectors:
- html body .header .nav{}
- .nav{}
+ html body .header .nav {}
+ .nav {}
There we can see pretty clearly that in the first example, the browser has to look out for four things, the `.nav` class, then the `.header` class, then the `body` element and then, finally, the `html` element (browsers read selectors right-to-left).
-With the second example the browser only needs to look for one thing; the `.nav` class. The browser has _four times_ less work to do to match that selector. Every time you write a selector try and trim as much losable stuff from it as possible. Instead of `ul.nav{}` (two checks) write `.nav{}` (one check). Instead of `.nav li a{}` (three) write `.nav a{}` (two).
+With the second example the browser only needs to look for one thing; the `.nav` class. The browser has _four times_ less work to do to match that selector. Every time you write a selector try and trim as much losable stuff from it as possible. Instead of `ul.nav {}` (two checks) write `.nav {}` (one check). Instead of `.nav li a {}` (three) write `.nav a {}` (two).
Now, [CSS selector performance is—by-and-large—not something we _really_ need to worry about any more](http://calendar.perfplanet.com/2011/css-selector-performance-has-changed-for-the-better/), but that doesn’t mean we should be wasteful. I’m sure none of us would miss a lost £5 but that doesn’t mean we go slipping banknotes into paper shredders… Selector efficiency _does_ exist and you might as well improve it where you **very easily** can.
-## Reduces location dependency
+## Reduces Location Dependency
-By keeping selectors short you are likely to be reducing the amount of descendant (e.g. `.sidebar .promo{}`) and child (e.g. `.sidebar > .promo{}`) selectors. By removing these descending types of selectors you are reducing the necessity for an element to live inside another one. Let’s reuse the `.sidebar .promo{}` example…
+By keeping selectors short you are likely to be reducing the amount of descendant (e.g. `.sidebar .promo {}`) and child (e.g. `.sidebar > .promo {}`) selectors. By removing these descending types of selectors you are reducing the necessity for an element to live inside another one. Let’s reuse the `.sidebar .promo {}` example…
-By having a selector like `.sidebar .promo{}` we are saying we want to target any promotional item that lives in an element with the class of `.sidebar`. This means that we are tied to always using that styling inside a certain element; we have a dependency on location.
+By having a selector like `.sidebar .promo {}` we are saying we want to target any promotional item that lives in an element with the class of `.sidebar`. This means that we are tied to always using that styling inside a certain element; we have a dependency on location.
-By replacing `.sidebar .promo{}` with something like `.secondary-promo{}` we can now place the element in question _anywhere_ we wish. In the sidebar—as before—but now also in the footer, or in the header, or after an article.
+By replacing `.sidebar .promo {}` with something like `.secondary-promo {}` we can now place the element in question _anywhere_ we wish. In the sidebar—as before—but now also in the footer, or in the header, or after an article.
By reducing descendants we can really reduce dependency and make things a lot more portable…
-## Increases portability
+## Increases Portability
So now that we’re not tied to locationally dependant selectors, we find that our components are a lot more portable. We can move things a lot more easily because our CSS doesn’t care where a thing lives, it just cares that it exists. Awesome!
-Another way to increase portability is to not qualify selectors. A qualified selector is one like `ul.nav{}` or `a.button{}` or `div.content{}`.
+Another way to increase portability is to not qualify selectors. A qualified selector is one like `ul.nav {}` or `a.button {}` or `div.content {}`.
-Qualified selectors are bad because they reduce efficiency (more checks than we really need) but—more importantly—because they tie us to specific elements. We can’t now use that `.button` class on an ` ` or a ``, for example. We can’t [apply `.nav` to an `` to make a breadcrumb](http://csswizardry.com/2011/09/the-nav-abstraction/).
+Qualified selectors are bad because they reduce efficiency (more checks than we really need) but—more importantly—because they tie us to specific elements. We can’t now use that `.button` class on an ` ` or a ``, for example. We can’t [apply `.nav` to an `` to make a breadcrumb](/2011/09/the-nav-abstraction/).
**Selectors should be element-agnostic**. Your CSS shouldn’t care what element you’re wanting to apply styling to.
Another way to make selectors more portable is to drop elements _altogether_. Take this, for example:
-.widget{}
+.widget {}
-.widget > h2{}
+.widget > h2 {}
Here we have a troublesome selector; what if that `` needs to become a ``? What if we need to add another, non-titling `` as a child of `.widget`? We’ve made ourselves a very rigid and unportable selector here. Instead we should have:
-.widget{}
+.widget {}
-.widget-title{}
+.widget-title {}
Now we can apply `.widget-title` to _any_ element—let’s say a ``—and can now also have any number of unclassed ``s in the widget without them adopting any title styling. Ossom!
-## Reduces chances of selector breakage
+## Reduces Chances of Selector Breakage
The longer a selector is, the more things the browser has to satisfy before it can match it. The more checks there are then—naturally—the more chance there is for something to go wrong.
-A (very exaggerated) selector like `body > div:nth-of-type(2) > article:first-child > p:first-child{}`—borrowed from my talk [Breaking Good Habits](https://speakerdeck.com/u/csswizardry/p/breaking-good-habits?slide=15)—has _ten_ checks; ten things that must be satisfied in order for the browser to make that match.
+A (very exaggerated) selector like `body > div:nth-of-type(2) > article:first-child > p:first-child {}`—borrowed from my talk [Breaking Good Habits](https://speakerdeck.com/u/csswizardry/p/breaking-good-habits?slide=15)—has _ten_ checks; ten things that must be satisfied in order for the browser to make that match.
-All that needs to happen is the location of the `div:nth-of-type(2)` to change or the `p:first-child` to become a `blockquote` or the `article:first-child` to no longer be a child of the `div:nth-of-type(2)` or _any manner_ of things before that selector will break. Simply replacing that with a class of `.intro{}` means that there is only one thing that could possibly break, and the chances of that happening are pretty much zero (you’d have to explicitly delete the class from your HTML to prevent a match).
+All that needs to happen is the location of the `div:nth-of-type(2)` to change or the `p:first-child` to become a `blockquote` or the `article:first-child` to no longer be a child of the `div:nth-of-type(2)` or _any manner_ of things before that selector will break. Simply replacing that with a class of `.intro {}` means that there is only one thing that could possibly break, and the chances of that happening are pretty much zero (you’d have to explicitly delete the class from your HTML to prevent a match).
Shorter selectors mean there is statistically less chance for things to go wrong.
-## Decreases specificity
+## Decreases Specificity
This is the big one! This is where it really matters!
-Longer selectors have a higher specificity. Specificity is a nightmare and **you should keep specificity as low as possible all of the time**. We already know that we [**do not use IDs in CSS**](http://csswizardry.com/2011/09/when-using-ids-can-be-a-pain-in-the-class/) but a chain of selectors are often just as bad (though not quite).
+Longer selectors have a higher specificity. Specificity is a nightmare and **you should keep specificity as low as possible all of the time**. We already know that we [**do not use IDs in CSS**](/2011/09/when-using-ids-can-be-a-pain-in-the-class/) but a chain of selectors are often just as bad (though not quite).
-A selector like `.widget > h2{}` has a higher specificity (as well as the other problems we discussed) than a selector like `.widget-title{}`.
+A selector like `.widget > h2 {}` has a higher specificity (as well as the other problems we discussed) than a selector like `.widget-title {}`.
-`.nav li a{}` has a higher specificity than `.nav a` (and is also less efficient). Reducing selector length reduces selector specificity and that is **very important**. High specificity leads to self-induced specificity battles that can only be won by making subsequent selectors _more_ specific (or using `!important`, shame on you). This is a terrible thing. The easiest way to reduce specificity (after _dropping IDs from your CSS **completely**_) is to keep your selectors short.
+`.nav li a {}` has a higher specificity than `.nav a` (and is also less efficient). Reducing selector length [reduces selector specificity](/2014/07/hacks-for-dealing-with-specificity/) and that is **very important**. High specificity leads to self-induced specificity battles that can only be won by making subsequent selectors _more_ specific (or using `!important`, shame on you). This is a terrible thing. The easiest way to reduce specificity (after _dropping IDs from your CSS **completely**_) is to keep your selectors short.
-## Can make code more forgiving
+## Can Make Code More Forgiving
This is a very specific but very decent example of how short selectors can make code more forgiving. However, I will warn you, you can argue two sides of what I’m about to tell you; you can argue that it makes your code a lot more flexible and can gracefully handle breakages **or** you could argue that it allows breakages in the first place by being too lenient. Anyway, here’s a true story…
In working on a pretty huge project at Sky I stuck to my own rules and coded a (vertical) nav bar CSS like so:
-.nav{ }
+.nav { }
-.nav a{ display:block; }
+.nav a { display:block; }
Now, there was a CMS error which went undetected where the markup getting spat out was:
@@ -126,13 +126,13 @@ Now, there was a CMS error which went undetected where the markup getting spat o