Often you want to display texts with frequent line breaks, such as addresses, poems, etc on websites. The HTML element <br> provides an easy way to break lines on web pages.

A code example

The below example uses <br> to create line breaks

<!DOCTYPE html>
<html lang="en">

	<title>A Sample Web Page</title>

		Mr. Alan Jones
		Evergreen Supplies
		21, Township Road
		Winnebago, North Carolina


The above example uses the HTML element <br> in many places to break lines. Here the HTML element <br> helps display a piece of address information on a website.

Few extra information

The HTML element <br> is a void element. It can’t contain any content. Thus, you don’t need a closing tag for the <br> element.

You may get confused when you come across a self-closing <br /> tag. Web developers use it sometimes to meet the backward compatibility with XHTML. You should always use the syntax, <br>.

It’s good programming practice to use the HTML tag <br> unless unavoidable. The overuse of the HTML tag creates a spaghetti code, hard to manage and style. The rule of thumb is to replace the <br> element with block elements or with CSS styling if possible.

Get my free e-book to prepare for the technical interview or start to Learn Full-Stack JavaScript