Originally published at: http://www.sitepoint.com/3-things-almost-one-knows-css/
Think you know CSS? If the results of a free CSS test I’ve offered online for the past six months are anything to go on, plenty of practicing developers don’t know CSS as well as they think. Out of over 3,000 people who have taken the test so far, the average score was just 55%.
But hey, an average isn’t that interesting by itself. I was more curious about which questions people were getting wrong. For this article, I’ve run the numbers, and zeroed in on three questions where people scored especially badly. I’ll talk you through each question, show you the answer that most people chose, and explain the correct answer.
It’s safe to say that if you take the test yourself after reading this, you’ll have an unfair advantage!
Question 1: How Best to Set line-height
This first question should have been easy for anyone who deals with text styles on a regular basis:
You want text on your website to be double-spaced by default. Which of the following
line-height
values is the best way to achieve this?
200%
2em
2
double
With four answers to choose from, you’d expect 25% of people to get the right answer by luck alone, and only 31% got this one right! Take a minute and pick out an answer for yourself, then read on.
First off, double
is a red herring. The only keyword value that line-height
accepts is normal
. I’m happy to say that only 9% of people fell for this one. The remaining three answers were all pretty popular, though.
The answer that most people selected is 2em
(39% chose this). Indeed, 2em
will certainly give you double-spaced text for the element it’s applied to; but so will 200%
, and only 21% liked that answer! Either ems are much more in fashion than percentages, or people don’t really understand them.