Open In App

How to Add a Non-breaking Space using &nbsp in HTML?

In HTML, the non-breaking space character, represented by &nbsp, is used to insert a space between elements or within text content that prevents the browser from merging consecutive spaces into a single space. This can be particularly useful for maintaining spacing or formatting in situations where regular spaces might be ignored.

Add Non-breaking Spaces in HTML with  

Example: The example below shows how to Add a Non-breaking Space with the &nbsp.

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

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Non-breaking Space Example</title>
</head>

<body>
    <p>This is a non-breaking space example.</p>
    <p>This&nbsp;is&nbsp;a&nbsp;non-breaking&nbsp;space&nbsp;example.</p>
    <p>
        Non-breaking&nbsp;space&nbsp;can&nbsp;be&nbsp;used&nbsp;
        to&nbsp;maintain&nbsp;spacing&nbsp;between&nbsp;words&nbsp;
        or&nbsp;elements.
    </p>
    <p>
        This&nbsp;&nbsp;&nbsp;is&nbsp;&nbsp;&nbsp;a&nbsp;&nbsp;&nbsp;
        line&nbsp;&nbsp;&nbsp;with&nbsp;&nbsp;&nbsp;multiple&nbsp;&nbsp;&nbsp;
        non-breaking&nbsp;&nbsp;&nbsp;spaces.
    </p>
</body>

</html>

Output:

Screenshot-2024-04-09-192259

Output 

Article Tags :