skip to content

In HTML, when is <br> the correct element to use, and what does <wbr> do?

level: juniorimportance: should knowfreq 32%

answer

  1. breaks that belong to the content
  2. not a spacing tool
  3. the other one is only permission
  4. nothing renders when unused
  5. hyphen comes from a different mechanism

basics

~20 s

Use br only for line breaks that are part of the content itself, such as the lines of an address or a poem — never for spacing. The wbr element marks a place where the browser may break a long unbroken string, and renders nothing otherwise.

solid answer

~50 s

`<br>` represents a line break that is part of the content: the lines of a postal address, lines of a poem, a song lyric. That is the spec's test — if removing the break would change the content rather than only its appearance, `<br>` is right. Using it to push things apart or to fake paragraph gaps is the classic misuse; separate blocks and their spacing are the job of block elements and CSS. `<wbr>` is unrelated in effect: it is a word-break opportunity, an empty element you place inside a long unbroken string such as a URL or an identifier to tell the browser it may break there if the line needs it. When no break is needed it renders nothing at all, and unlike the soft hyphen `&shy;` it never adds a hyphen character.

code

html · 7 lines
html
<p>
  Acme Supplies Ltd<br>
  114 Harbour Road<br>
  Bristol BS1 4TY
</p>

<p>https://example.com/<wbr>catalogue/<wbr>2026/<wbr>spring-collection</p>

go deeper

for a junior

Be ready to say that br is for line breaks that belong to the content, such as an address, and to name spacing between paragraphs as the wrong use.

for a middle

Explain the mechanics precisely: br is a void content-level break, wbr is a silent break opportunity that renders nothing, and the hyphen at a break comes from the soft hyphen entity instead.

for a senior

Show the review instinct — spot br used as a spacing or layout device in components and templates, and explain what the false content claim costs in maintenance and in screen-reader output.

for a principal

Own the boundary in your codebase: markup states what the content is, presentation lives in CSS, and long-string overflow is handled by a deliberate wbr or hyphenation convention rather than ad-hoc breaks.

## What `<br>` actually means `<br>` is a void element representing a line break **in the content**. The specification is unusually direct about it: `<br>` elements must be used only for line breaks that are actually part of the content, as in a poem or an address. The test is easy to apply in an interview: > If you deleted the break, would the content itself be wrong — or would it merely look different? An address whose lines run together is wrong. A poem whose lines run together is a different poem. A paragraph that sits closer to the next one merely looks different, and that is a styling change, not a content change. ```html <p> Acme Supplies Ltd<br> 114 Harbour Road<br> Bristol BS1 4TY </p> ``` ## What `<br>` is not for The misuses all share one shape: using a content element to achieve a visual result. - **Blank space between paragraphs.** Two `<p>` elements are two paragraphs; the gap between them is CSS. A stack of `<br><br>` produces neither semantics nor a maintainable gap. - **Faking a list.** Lines separated by `<br>` are one run of text. List markup carries the item count and structure that a screen reader announces; `<br>` throws that away. - **Forcing a heading or a marketing line to wrap at a chosen word.** That is purely presentational, and it breaks at other viewport widths anyway. - **Formatting an address or form layout into columns.** Layout is a styling concern. A useful reframing for candidates: `<br>` is not "the newline element", because newlines in HTML source are collapsed as whitespace. It is the element that says *this content is written as separate lines*. ## What `<wbr>` does `<wbr>` is also a void element, but its meaning is a **word break opportunity**: a point where the browser is allowed to break the line if it needs to, and where it will not break otherwise. It is the tool for long unbroken strings that would otherwise overflow or force horizontal scrolling — URLs, file paths, hashes, long identifiers, chemical names: ```html <p>https://example.com/<wbr>very/<wbr>long/<wbr>path/<wbr>segment</p> ``` Two properties are worth stating explicitly, because they are what interviewers probe: 1. **It renders nothing when it is not used.** No space, no glyph, no visual artefact. It is purely permission. 2. **It adds no hyphen.** The break just happens. If you want a hyphen to appear at the break point, that is the soft hyphen character entity `&shy;`, which is a different thing: `&shy;` inserts a hyphen when the break is taken and shows nothing when it is not. So the pair is easy to remember: `<wbr>` means "you may break here, silently"; `&shy;` means "you may break here, and print a hyphen if you do". ## How the two interact with assistive technology A `<br>` typically causes a screen reader to treat the text as continuing on a new line, which is harmless when the break is genuinely part of the content and merely noisy when it is not — another reason a `<br><br>` layout hack is a poor idea. `<wbr>` contributes no content and is not announced. ## Choosing correctly, quickly - Lines that belong to the content (address, poem, lyric, a short verse-like caption) → `<br>`. - Separate blocks of prose → separate block elements, with spacing handled in CSS. - Structured items → list markup, not lines. - A long unbreakable string that overflows its container → `<wbr>` at sensible break points, or `&shy;` if a hyphen is wanted. ## Pitfalls Expecting `<wbr>` to force a break — it never forces, it only permits. Writing `<br/>` or `<br></br>` and thinking the form matters: `<br>` is void, it takes no closing tag, and the self-closing slash is tolerated but meaningless in HTML. Sprinkling `<wbr>` through ordinary prose, where the browser already breaks at spaces and the markers only clutter the source. And reaching for `<br>` in a component because a designer asked for "a bit more room" — that request is a stylesheet change, not a markup change.

  • What is the difference between <wbr> and the soft hyphen &shy;?
    Both mark a permitted break point inside a word or string, and both render nothing when the break is not taken. The difference is what appears when it is: `<wbr>` breaks silently, while `&shy;` prints a hyphen at the break. Use `&shy;` for hyphenating real words, and `<wbr>` for URLs, paths and identifiers where an inserted hyphen would be misread as part of the string.
  • A designer asks for more space between two paragraphs. Why is adding <br> the wrong answer?
    Because the gap is a presentational request and `<br>` is a content element — it asserts that the text is written as separate lines, which is not true here. The markup then carries a false claim, the spacing is unadjustable per breakpoint, and screen-reader users hear extra line breaks. The correct change is a margin in CSS on the existing block elements.
  • Does <wbr> force a line break at that point?
    No. It only grants permission: the browser breaks there if the line needs breaking, and ignores it otherwise, rendering nothing. This is the usual misconception — people insert it and are surprised nothing happened on a wide viewport. If a break must always occur, the content genuinely has two lines and `<br>` is the element for it.

saying these in an interview costs you the question

  • Uses stacked br elements to create vertical space
  • Thinks wbr forces a break wherever it appears
  • Believes wbr inserts a hyphen like a soft hyphen
  • Separates list items with br instead of list markup
  • Insists br needs a closing or self-closing form

context