Wednesday, 11 October 2017



Non breaking space in HTML

Non breaking space in HTML is &nbsp. &nbsp is used to add space in document but it shall not be used as usual space between words. It’s a space where line break will not happen. If you want to add more than one space between words you shall use &nbsp.

Example

Here is an example of how &nbsp is used in HTML. So open your notepad paste the following code and save as “try1.html”
<html>
            <head>
                        <title>Non Breaking Space</title>
            </head>
<body>
<h1>Non Breaking Space</h1>
<p>
This is a line without npsb. now will come 5 spaces     end.
</p>
</body>
</html>
Open the document in your web browser to see the output. For this right click on document, click open as and select the browser. The output will be:
Now again open notepad, write the following code and save as “try2.html"
<html>
            <head>
                        <title>Non Breaking Space</title>
            </head>
<body>
<h1>Non Breaking Space</h1>
<p>
This is a line without npsb. now will come 5 spaces&nbsp&nbsp&nbsp&nbsp&nbsp end.
</p>
</body>
</html><html>
            <head>
                        <title>Non Breaking Space</title>
            </head>
<body>
<h1>Non Breaking Space</h1>
<p>
This is a line without npsb. now will come 5 spaces&nbsp&nbsp&nbsp&nbsp&nbsp end.
</p>
</body>
</html>
Open this in web browser,the output will be

Here you can clearly see that using &nbsp has forced spaces between words.

Non breaking space in HTML Non breaking space in HTML is &nbsp. &nbsp is used to add space in document but it shall not be us...