Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

HTML element: br

The line-break element marks a move to a new line that belongs to the content itself, such as in a postal address or a line of verse.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

first line<br>second line

Use br where line preservation carries meaning; separate paragraphs require p, while ordinary source newlines normally collapse as whitespace.

br is void: it has no children or end tag, and writing </br> is nonconforming HTML that the parser can repair in surprising ways.

Do not build spacing with a series of br; set visual space with CSS such as margin or padding while retaining the proper content structure.

The example compares textContent with layout-aware innerText and counts two br elements in a three-line address.

Examples

<!doctype html>
<meta charset="utf-8">
<p id="postal">CKTIS<br>Warsaw<br>Poland</p>
<output id="result"></output>
<script>
const postal = document.querySelector("#postal");
const rendered = postal.innerText.replaceAll("\n", "|");
document.querySelector("#result").textContent = `breaks=${postal.querySelectorAll("br").length}; text=${postal.textContent}; rendered=${rendered}; children=${postal.childNodes.length}`;
</script>

Result

breaks=2; text=CKTISWarsawPoland; rendered=CKTIS|Warsaw|Poland; children=5

The result verifies that the breaks affect rendered lines but do not insert newline characters into the DOM text.

Sources