<br> is obsolete?

Asked

Viewed 897 times

40

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

  • 17

    But <br> is an element that defines line breaking in texts, nor should it be used to define the layout.

  • I believe it is because with spacing you can have more dynamism because with br spaces will be automatic already with spacing you can define.

  • One remark, is that after rewriting HTML 4.01 in (x)HTML 1.0 by W3C - where the syntax for XML fits - it is not necessary to include a closing tag, you must flag the tag itself: <br />

  • @Andersoncarloswoss this was common formerly, it was the form of structuring, it was the base of Table and BR .

  • I think Br is in vogue especially here in Portugal, zoando so, but br and good to edit texts and not make the layout itself in my opinion

2 answers

57


No, it’s not obsolete.

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

<br> Elements must be used only for line breaks that are Actually part of the content, as in poems or Addresses.

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

Documentation of MDN also says:

The line-breaking HTML element <br> produces a line break in a text (Carriage-Return). It is useful to write poems or an address where the line division is significant.

For any organization of layout, the recommended will be to find another element that has been specified for this (for example, if <br> sets the line break between two elements inline, it will be better to use elements block) or use CSS for formatting.

  • 17

    Just remembering that breaking lines in text is not paragraphing.

  • Carriage Return? What a prejudice!!!! Why not Line Feed?

  • 4

    @LINQ The practical effect is the sum of both. Their difference is more evident in printers with mechanics similar to matrix or daisy. If you send a CR and more text, the head goes back to the beginning and writes over the existing line. If you send an LF in the middle of the line, the text will come out in the next line but... from the middle on. That’s why the use of CRLF has consolidated. The applications is that they did not "imitate" on screen the behavior.

  • @Bacco was just a joke hehehe. Anyway, you could comment on this in my question about these guys, right? Fits right in the context.

  • 3

    @LINQ ah yes, I just took the hook to leave a little history :) - I researched a little, I saw that practically nobody talks about it. I need to produce an image illustrating.

  • @Bacco yes, that’s really very interesting.

  • The question was very objective. If it is obsolete, it is, because it used to be common to use br for layout spacing, and nowadays there is no need for more . Here the question does not revolve around doing search and give answer edited and formatted, we are dealing with experience of the evolution of code practices, etc. Having lived other times and known other tendencies in html markup and not in the good practice of accentuation .

  • 2

    @If Davidaugustus disagrees with the answer and has something to add, he can answer the question as well. This is how the community works: everyone collaborates a little and everyone learns. I completely disagree with what I said and I don’t see what changes in my answer.

  • We will only believe in the future of the World Wide Web, since we deviate from the standards implemented by its creators, and we must conform to the spelling coder standard. But if we ever get back to a solid, reliable, scale-based markup, we would have used XML and JSON to receive data for the page as a REST architecture. Then in this case you could not use the <br> because it is not compatible to break the line with the text formatting. So, this way, for those who develop only "Hypermedia" makes no difference. The browser will understand BR wherever.

  • 5

    @Davidaugustus still did not understand his point of view. I could elaborate a reply presenting it in full?

  • @Andersoncarloswoss I’ve seen in some codes use <br/> instead of <br>, both are equivalent?

  • 1

    @Thiagokrempser You can read about this in https://answall.com/q/46370/5878

Show 7 more comments

1

As you can see in the example with the use of br vc has no control over the spacing of the elements as vc has using div for example, that gives easily to you 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>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.