Open In App

How to break line without using <br> tag in HTML / CSS ?

Improve
Improve
Like Article
Like
Save
Share
Report

Use block-level elements to break the line without using <br> tag. There are many ways to break the line without using <br> tag. In this article we will see how to break the line without using a br tag and some of the methods to do so are as:

Methods

Description

white-space: pre;

It is used to make elements act like <pre> tag.

display: block;

It sets the display property of elements to block.

Example 1: This example uses white-space to pre to break the line.

html




<!DOCTYPE html>
<html>
 
<head>
    <title>
        Line break without using br tag
    </title>
</head>
 
<body style="text-align:center;">
 
    <h1 style="color:green;">
        GeeksForGeeks
    </h1>
 
    <div style="white-space: pre">
        GeeksforGeeks
        GeeksforGeeks
    </div>
</body>
 
</html>


Output:

Example 2: This example uses display property to break the line.

html




<!DOCTYPE html>
<html>
 
<head>
    <title>
        Line break using display property
    </title>
 
    <style>
        p span {
            display: block;
        }
    </style>
</head>
 
<body style = "text-align:center;">
 
    <h1 style = "color:green;" >
        GeeksForGeeks
    </h1>
         
    <p>
        <span>GeeksforGeeks_1</span>
        <span>GeeksforGeeks_2</span>
    </p>
</body>
 
</html>                    


Output:



Last Updated : 30 Jan, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads