A
A
Alexander Sharomet2016-01-19 23:51:05
css
Alexander Sharomet, 2016-01-19 23:51:05

How to correctly calculate line-height for different headings?

Hello.
Tell me how to correctly calculate the line-height for the headings h1 ... h6 and in general in rem
How can I correctly format this in scss?
for example:

html{
font-size:16px
}
body{
font-size:1rem
}
h1{
font-size:3rem;
line-height:??????
}
h2{
font-size:2.5rem;
line-height:??????
}

I just use this build
$base-font-size:16px;
@function rem($px, $base: $base-font-size) {
    @return ($px / $base) * 1rem;
}
p{
font-size:rem(14px);
}

But how to calculate the line-height again

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
kordenv, 2018-05-16
@sharomet

I use

* {
    line-height: 1.5;
}

html,
body {
    font-size: 62.5%;
}

body {
    font-size: 1.6rem;
}

it is convenient, i.e. 1rem will be considered as 10px and based on this you already calculate
, but as for line-height, it seems like 1.4 - 1.6 is considered optimal for reading, I use 1.5

P
pvasili, 2019-08-08
@pvasili

There is no universal value.
It has its own for each specific font.
I recommend reading: https://iamvdo.me/en/blog/css-font-metrics-line-he...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question