So I have an <h2>
element and a <p>
right below it and I'd like to space them out a little bit. Currently I'm just using a <br>
between them but I was wondering if there's a way to do it in CSS? It can be applied to all the <h2>
and <p>
elements on my page. Thanks!
Asked
Active
Viewed 1,132 times
0
-
https://www.w3schools.com/css/css_margin.asp – Bryan Dellinger Dec 04 '20 at 00:28
-
You can use add a margin at the bottom - see this https://www.w3schools.com/cssref/pr_margin-bottom.asp. – rby Dec 04 '20 at 00:28
-
Consider using the `margin-top` property (e.g. `margin-top: 2px`) on the second element. – Maf Dec 04 '20 at 00:28
1 Answers
0
you can control line-spacing in one HTML tag only. So if you have
<h2 style="line-spacing:40px;">Hello World</h2>
<p>Lorem ipsum</p>
It will only affect the <h2>
"Hello World" and not the <p>
tag with the text Lorem Ipsum. You need to give the a margin-bottom such as this:
<h2 style="margin-bottom:40px;">Hello World</h2>
<p>Lorem ipsum</p>

user5854648
- 1,029
- 2
- 11
- 36