Line breaks and hr tag in HTML

Line breaks and hr tag in HTML

The line break is used to decide where the text will break on a line or continue to the end of the window. It can be used to move the control to the next line. The tag is used to end a line without inserting a new paragraph. The has no closing tag.

Example of line break

The following text will appear in two different lines.

Without BR tags:

<p>this is sentence one. This is sentence two. </p>

Output:

this is sentence one. This is sentence two.

With BR tag

<p>this is sentence one. <br> This sentence two.</p>

Output:

This is sentence one. (Next sentence is going two next lines due to br tag)
This is sentence two.

Practice:

Challenge for you:
Write HTML code that displays text in four lines using br tag.

Step 1: Open notepad and type the following code:

<html>
	<head>
		<title> WU Exercise</title>
 </head>
<body>
	<p>I have three Friends: <br>Ali<br>Hamza<br>Numan</p>
</body>
</html>

Step 2: Save the file as “wuexcricese.html”

Step 3: Double click on the file. The web page will appear in the browser with the following result

line break

HR tag

hr tag is used to add the horizontal line in your paragraph or with any elements. Use this following code and see the result and decide what is the difference between hr and br tag.

<html>
	<head>
		<title> WU Exercise</title>
 </head>
<body>
	<p>I have three Friends: <hr>Ali<hr>Hamza<hr>Numan</p>
</body>
</html>

Output:

line break and hr tag

Attribute:

The BR and HR tag has no important attribute and these both have no closing tag.

Reference

If you want to learn more about HTML then visit the official website: Visit

Visit the HTML tutorial list. And make strong your HTML concept. Click here. wuschools.com is always written about the HTML concept for the HTML lover. Ang writes about how HTML makes your life easy if you are a web site developer. We help you to continue your learning.

Leave a Reply

Close Menu