Remove top/bottom padding from H (heading) tags

Williams

New Member
#1
I've seen lots of posts trying to address this but my padding persists. How (if possible) can you remove the top/bottom padding/margin to to your H1, H2, H3 tags etc.
Mã:
h1 {
  outline: 1px solid red;
  padding: 0px;
  margin: 0px;
}
Mã:
<h1>hello world</h1>
 

Admin

Administrator
Thành viên BQT
#2
You already removed the top and bottom padding and margin. The space you see above and below the letters in your example is due to the line-height (the default settings depend on your browser). You can reduce that by adding a different setting, but always keep in mind that certain letters need the space above and below, which also depends on the used font which can vary concerning the amount of vertical space needed for these:
Mã:
h1 {
  border: 1px solid green;
  padding: 0px;
  margin: 0px;
  line-height: 100%;
}
Mã:
<h1>hello - mind letters like these: jQÜØgpÄy</h1>
 
OP
OP
W

Williams

New Member
#3
I'm gonna take the walk of shame on this one. I neglected to consider the spacing is for letters that go below the line of writing, i.e. g y p q
 

Từ khóa phổ biến

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top