Is it sometimes bad to use <BR />?
Is it sometimes bad to use <BR/>
tags?
I ask because some of the first advice my development team gave me was this: Don't use <BR/>
; instead, use styles. But why? Are there negative outcomes when using <BR/>
tags?
The main reason for not using <br>
is that it's not semantic. If you want two items in different visual blocks, you probably want them in different logical blocks.
In most cases this means just using different elements, for example <p>Stuff</p><p>Other stuff</p>
, and then using CSS to space the blocks out properly.
There are cases where <br>
is semantically valid, i.e. cases where the line break is part of the data you're sending. This is really only limited to 2 use cases - poetry and mailing addresses.
I think your development team is refering to <br />
in place of margin spacing. To make empty space between elements, use padding / margin styling via CSS.
Bad use of <br />
:
<div>
Content
</div>
<br />
<br />
<br />
<br />
<div>
More content...
</div>
Good use of <br />
:
<style>
div {
margin-top:10px;
}
</style>
<div>
Content<br />
Line break
</div>
<div>
More content...
</div>
Generally, <br/>
is an indication of poor semantic HTML. The most common case is using <br/>
to declare paragraph separations, which there are much better ways to do it semantically. See Bed and BReakfast.
There are occasions where it is the proper tag to use, but it is abused often enough that people adopt a "do not use" mentality as to force better semantic thinking.
What was meant by your team was probably not to use <br>
s to split between paragraphs.
For example :
<p>I am a paragraph</p>
<p>I am a second paragraph</p>
is the better way to do that, because you can then easily adjust the spaces between paragraphs through CSS. Other than that, I can not think of anything speaking against line breaks as such.
Same concept applies to why we don't use tables for layout - use tables for tables and CSS for layout.
Use <br/>
for break lines in a block of text and CSS if you want to affect the layout.