I
I
Igor Pavlenko2016-02-19 09:40:57
css
Igor Pavlenko, 2016-02-19 09:40:57

How to remove the top margin?

How to remove the top margin from the title? It is clear that this is due to the line-height, but it is not clear how to avoid this. Crutches like margin-top: -13px; use is not suitable. There are many moments in the project when it is necessary to align it this way (because the headers are of different sizes). Is there any generic method? I have not found a solution to this problem anywhere.
Example on JSFiddle
b0b7f1e92b7642ee8f8a8c80b2548861.png
PS
Solved the problem like this https://jsfiddle.net/up26atho/3/ (line-height in percent)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem Lisovsky, 2016-02-19
@torrie

It all depends on the font.
If the font has an indent at the top of the letters, then the only way to get rid of it is by adjusting the line-height to the font-size. If not, then everything will be automatic when line-height == font-size

M
Mikhail, 2016-02-19
Chirskiy @chirskiy_mixail

In 1 set the margin of the body to zero, in 2 for the body set line-height: 1;
Well, as Artem Lisovsky said , everything depends on the font, well, margin-top: -13px is clearly superfluous here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question