When you have to specify the same .css class for multiple headers <h3>
, is it better to use the <br>
tag or is it better to repeat the header while specifying the same style class over and over again? In this specific scenario, I can't put styling on the surrounding <div>
Which one is best practice and why?
Code example while using <br>
tags:
<div class="more_room_left | more_room_top">
<h5 class="no_margin_top_bottom">
*location?.streeth* *location?.number*
<br> *location?.postcode* *location?.city*
<br> *location?.country*
<br>
</h5>
</div>
Code example using different headers:
<div class="more_room_left | more_room_top">
<h5 class="no_margin_top_bottom">*location?.streeth* *location?.number*</h5>
<h5 class="no_margin_top_bottom">*location?.postcode* *location?.city*</h5>
<h5 class="no_margin_top_bottom">*location?.country*</h5>
</div>
Visual example:
EDIT:
After reading more about when to use the <br>
tag, I've concluded that in my case the <br>
tag has no value and is considered a hack. I reworked the way I'm styling the headers <h3>
, which are now paragraphs <p>
, to fit the styling I need without using the <br>
tag. This solution was handed to me through an already removed answer, so I can't give credit.
HTML
<div class="address_container | more_room_left | more_room_top">
<p>*location?.streeth* *location?.number*</p>
<p>*location?.postcode* *location?.city*</p>
<p>*location?.country*</p>
</div>
CSS
.address_container > p {
margin-top: 0;
margin-bottom: 0;
}
` tags but that's just me.
– apokryfos Mar 23 '17 at 08:58