Reputation: 119
h3 with white space at the top and the bottom
I have some white space around my h3. To align it the same as some pictures I want to delete the white space at the top and the bottom of the h3. The margin is 0, but there is still space between the top and the bottom of the text. How do I solve this?
this is my code:
<html>
<head>
</head>
<body>
<h3>title</h3>
</body>
</html>
Upvotes: 3
Views: 4624
Reputation: 5092
Just Remove The Browser Default
Margin
andPadding
Apply Top Of Your Css.
<style>
* {
margin: 0;
padding: 0;
}
</style>
NOTE:
html elements
before writing your css.OR [ Use In Your Case
]
<style>
*{
margin: 0px;
padding: 0px;
}
h3 {
margin-top: 0px;
}
</style>
DEMO:
<style>
*{
margin: 0px;
padding: 0px;
}
h3 {
margin-top: 0px;
}
</style>
<html>
<head>
</head>
<body>
<h3>title</h3>
</body>
</html>
Upvotes: 0
Reputation: 402
As noted before, it is hard to reproduce your situation without the full CSS code that you have also.
However, a quick test of this gave me a h3
without any whitespace:
<html>
<head>
</head>
<body style="padding: 0;">
<h3 style="margin: 0; padding: 0;">test</h3>
</body>
</html>
It is probably browser dependent what the default margins/paddings on both the body
and h3
elements are. I hope this helps you.
Upvotes: 0
Reputation: 1140
Remove the padding of the container element (in your example, the <body>
tag):
body { padding: 0 }
Upvotes: 0
Reputation: 32066
You're confused about what the whitespace is. It's the full line height of the text, which accounts for potential above and below text characters, like accents and dangling letters. If you want to squish this whitespace (not recommended), set the line height to something smaller than the default, like
line-height: 0.8em;
Upvotes: 2