Skip to content

Instantly share code, notes, and snippets.

@AllThingsSmitty
Created April 16, 2015 14:38
Show Gist options
  • Save AllThingsSmitty/12dfd5efe97882bc4967 to your computer and use it in GitHub Desktop.
Save AllThingsSmitty/12dfd5efe97882bc4967 to your computer and use it in GitHub Desktop.
CSS trivia

###1. How best to set line-height Q. 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

A. First off, double is a red herring. The only keyword value that line-height accepts is normal. 2em will certainly give you double-spaced text for the element it's applied to; but so will 200%.

The correct answer is 2. Always specify line-height as a unitless number; that way, descendent elements that specify a different font-size will inherit that number rather than a fixed line height.

Setting line-height to 2 tells the browser to preserve the font-size/line-height ratio even when the font size changes. The line height for the body will be 24pt, but for the heading's 24pt font, the line height will automaticlly increase to 48pt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment