br is obsolete?

26

With the advent of responsive / adaptive / fluid layouts, it is becoming less common to use <br> to define layout spacing. Is not it recommended in these modern layouts or is it just a matter of programming practice to separate responsibility for CSS?

    
asked by anonymous 07.06.2018 / 16:11

3 answers

44

No, it is not obsolete.

The <br> element defines a new line break in text, not in layouts . Semantically speaking, such an element should never be used as a structure for layout . Just look at what the W3C / WHATWG says:

  

<br> elements should be used only for line breaks that are actually part of the content, as poems or addresses.

That is, it still exists, is nowhere near obsolete and should be used for what has been done: line breaks in texts.

MDN documentation also says:

  

The wrapper HTML element <br> produces a line break in a text (carriage-return). It is useful for writing poems or an address, where line division is significant.

For any layout organization, the recommended one is to look for another element that has been specified for this (for example, if <br> defines the line break between two inline elements >, elements), or use CSS for formatting.

    
07.06.2018 / 16:21
2

As you can see in the example with the use of br you have no control over the spacing of the elements as you have using div for example, which gives you easily control by CSS .

div {
  padding: 50px;
}
<h3>Utilizando br</h3>
Texto qualquer
<br>
<br>
Outro texto qualquer
<br>
<br>
<hr>
<h3>Utilizando div
<div>Texto qualquer</div>
<div>Outro texto qualquer</div>
    
07.06.2018 / 16:28
0

I think it's because with spacing you get more dynamism because with br spaces are automatic and with spacing you can define.

    
07.06.2018 / 16:13