I have stumbled across a problem that I can not seem to solve in any way, maybe I am using div
s in a wrong way?
.greeting h1 {
font-family: 'Raleway', sans-serif;
font-weight: lighter;
font-size: 100px;
text-align: center
}
.greeting h2 {
font-family: 'Raleway', sans-serif;
font-weight: lighter;
font-size: 35px;
line-height: 0px;
text-align: center
}
<div class="greeting">
<h1>Hi.</h1>
<h2>Select a group</h2>
</div>
This is the outcome:
I want to decrease the space between my <h1>
and <h2>
, and I found out that the way to do that was to set line-height
in h1
to 0px
.
But as I do that my entire page moves up like so:
I want to keep the text at the same position as it was before I change the line-height
. I am suspecting that I am using the div class function wrong. This is more of theoretical question.
headings
h1
toh6
havemargin
by default, so you need to reset it, setting:margin:0
.HTML heading tags have some default CSS values applied in most browsers. Following are the values of
h1
andh2
that are applied to them by default, so you need to override themargin-bottom
ofh1
andmargin-top
ofh2
if you want to decrease the spacing between yourh1
andh2
.Just add the following lines