Understanding the Line Break Tag in HTML
Working with Text
In this lesson, we will learn how to use the line break tag to create line breaks and improve the readability of your HTML code.
What is Line Break Tag in HTML
The Line Break Tag, also known as the <br> tag, is a self-closing tag in HTML. It allows you to insert a line break or blank line between two elements in HTML. This tag is used to break the line of text or content, making it easy to read and understand.
The syntax of the Line Break Tag is straightforward. You need to use <br> at the point where you want to break the line. Unlike other HTML tags, the Line Break Tag is self-closing, which means it does not require a closing tag.
Here's are some examples of how to use line break tag in HTML:
Example 1: Single Line Break
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Line Break Tag Example</title>
</head>
<body>
<p>This is first line of text.<br>This is second line of text.</p>
</body>
</html>
Sometimes you may need to create multiple line breaks between two elements. In such a case, you can use the Line Break Tag multiple times to achieve the desired effect. Here is an example:
Example 2: Multiple Line Breaks
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Line Break Tag Example</title>
</head>
<body>
<p>This is first paragraph of text.</p>
<br>
<br>
<br>
<br>
<p>This is second paragraph of text after 4 line breaks.</p>
</body>
</html>