{"id":201,"date":"2007-01-05T09:44:54","date_gmt":"2007-01-05T07:44:54","guid":{"rendered":"http:\/\/www.maratz.com\/blog\/archives\/2007\/01\/05\/how-to-set-leading-with-ems-in-css\/"},"modified":"2010-04-12T16:59:25","modified_gmt":"2010-04-12T15:59:25","slug":"how-to-set-leading-with-ems-in-css","status":"publish","type":"post","link":"https:\/\/www.maratz.com\/blog\/archives\/2007\/01\/05\/how-to-set-leading-with-ems-in-css\/","title":{"rendered":"How to set leading with ems in CSS"},"content":{"rendered":"<p><img loading=\"lazy\" src=\"\/img\/2007\/TYPE_in_CSS.gif\" width=\"420\" height=\"136\" alt=\"TYPE in CSS\" \/><\/p>\n<p>Recently, a faithful <a href=\"http:\/\/typetester.maratz.com\/\">Typetester<\/a> fan wrote:<\/p>\n<blockquote><p>I choose Verdana size 1.2 em \/ leading 1.6 em (that should be size 12px \/ line-hight or line spacing 16 px as you described in <a href=\"http:\/\/www.maratz.com\/blog\/archives\/2005\/10\/21\/typetesters-base-font-size\/\">Typetester\u2019s base font size<\/a> and made a screenshot from Firefox 1.5 \/ Win.<\/p>\n<p>I compared the screenshot with its font size and line spacing in Photoshop with Verdana size 12 px \/ line spacing 16px. The result is that leading 1.6 em is bigger than line spacing 16 px in Photoshop, it is around 19 px. Where is the mistake?<\/p><\/blockquote>\n<h2>Terminology confusion?<\/h2>\n<h3>Line-spacing<\/h3>\n<p>Line-spacing is the distance between base lines of the two neighbor text rows<\/p>\n<h3>Leading<\/h3>\n<p><cite>According to <a href=\"http:\/\/www.w3.org\/TR\/REC-CSS2\/visudet.html#line-height\">W3C<\/a>:<\/cite><\/p>\n<blockquote>\n<p>Since the height of an inline box may be different from the font size of text in the box (e.g., &#8216;line-height&#8217; > 1em), there may be space above and below rendered glyphs. The difference between the font size and the computed value of &#8216;line-height&#8217; is called the leading. Half the leading is called the half-leading.<\/p>\n<\/blockquote>\n<p><cite>According to Robert Bringhurst\u2019s book The Elements of Typographic Style:<\/cite><\/p>\n<blockquote>\n<p>Vertical space is  metered in a different way. &#8230; This unit is the leading, which is the distance from one base line to the next.<\/p>\n<\/blockquote>\n<p>The word <em>leading<\/em> is after thin strips of lead, inserted between lines of type in letterpress printing.<\/p>\n<h3>Line-height<\/h3>\n<p>Line-height is a CSS property which is equivalent to line-spacing. It can be computed, inherited or specified.<\/p>\n<h2>How it works in CSS<\/h2>\n<p>If set with relative unit (like em or percentage), line-height is always computed from the element&#8217;s font-size, whether the sizing is explicitly specified for the given element or simply inherited by a cascade. The 12px font size from our example is multiplied by 1.6, which really <em>is<\/em> 19px (19.2 to be precise).<\/p>\n<p>If one\u2019s attempt is to set the 16px leading, then she should divide the 16px from Photoshop with the 12px font size. That simple calculation would result in 1.333em (or 133.3%).<\/p>\n<h2>Related reading<\/h2>\n<ul>\n<li><a href=\"http:\/\/www.w3.org\/TR\/REC-CSS2\/visudet.html#line-height\">Line height calculations: the &#8216;line-height&#8217; and &#8216;vertical-align&#8217; properties<\/a><\/li>\n<li><a href=\"http:\/\/meyerweb.com\/eric\/thoughts\/2006\/02\/08\/unitless-line-heights\/\">Unitless line-heights<\/a><\/li>\n<li><a href=\"http:\/\/www.24ways.org\/2006\/compose-to-a-vertical-rhythm\">Compose to a Vertical Rhythm<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Transform line-spacing from Photoshop to line-height rule in CSS.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,7],"tags":[25,28,33,82],"_links":{"self":[{"href":"https:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts\/201"}],"collection":[{"href":"https:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/comments?post=201"}],"version-history":[{"count":0,"href":"https:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/posts\/201\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/media?parent=201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/categories?post=201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.maratz.com\/blog\/wp-json\/wp\/v2\/tags?post=201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}