Open In App

HTML nbsp

Last Updated : 10 Jan, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

HTML nbsp is an abbreviation of Non-Breaking Space. A non-breaking space is a space that will not break into a new line. It also defines that text or elements do not break on any viewport. It can also used for giving extra spaces between the elements.

Syntax

 

Prevent Line Break

To prevent line breaks, the   entity is used. It is often used to prevent line breaks between two words or elements. When you use   between any words or any elements, it makes sure that the browser renders the words or elements together on the same line.

Example: In this example, we will illustrate the example of HTML nbsp.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, 
                   initial-scale=1.0">
    <title>html nbsp</title>
  
    <style>
        div {
            font-size: 20px;
            font-weight: 700;
            color: green;
            margin-bottom: 50px;
        }
  
        p {
            margin-bottom: 50px;
        }
    </style>
</head>
  
<body>
    <div>
        Web Design is a field related to designing
        websites on the Internet. Without a good
        design, a website fails to perform well and
        cannot produce a good impact on the user.
    </div>
    <p>The above text used HTML NBSP between cannot and produce</p>
    <div>
        Web Design is a field related to designing
        websites on the Internet. Without a good
        design, a website fails to perform well and
        cannot produce a good impact on the user.
    </div>
</body>
  
</html>


Output:

snapnb

Spaces with nbsp

We can give as much spaces as we want by using &nbsp multiple times.

Example: In this example we will illustrates how to give extra spaces using nbps.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, 
                   initial-scale=1.0">
    <title>html nbsp</title>
    <style>
        div {
            font-size: 20px;
            font-weight: 700;
            color: green;
            margin-bottom: 50px;
        }
  
        p {
            margin-bottom: 50px;
        }
    </style>
</head>
  
<body>
    <div>
        Web Design is a field
        related     to
        designing websites on the Internet.
    </div>
    <p>
        The above text used HTML NBSP
        between cannot and produce
    </p>
    <div>
        Web Design is a field related
        to designing websites on
        the Internet.
    </div>
</body>
  
</html>


Output:

nbsp



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads