Book Top Rank with Contact Details visibility for your Business, Profession, Products or Services

3 Ways to Add HTML Space Between Words on Same Line

Question by Saravana s On 15 August 2022, 17:05:10

(Page Views: 213)

Answer by Saravana s On 15 August 2022, 17:07:34

3 methods to add HTML space between words

1. Non-breaking space

All elements allow non-breaking space. If you use a single space code twice, it will be displayed as a double space. If you write content without using any tags, your space will be changed into " " automatically in the backend.

  • The Code " " to add a single white space.
  • The Code " " to add Double white spaces.
  • The Code " " to add Four white spaces.

Code:

<h1> Hello&nbsp;Everyone </h1>
<h1> Hello&ensp;Everyone </h1>
<h1> Hello&emsp;Everyone </h1>

Result

html space between words on same line

2. HTML <pre> tag

You can easily add multiple spaces in HTML using pre-tag. The pre element represents a block of preformatted text, in which structure is represented by typographic conventions rather than by elements. This tag is the only one that allows multiple spaces, even if you add multiple whitespaces between words, it will display correctly. So you don't need to add any code like the first method. To add multiple spaces in the heading you need to add <h1> tag inside <pre> tag and give your content inside it as shown in the below code:

<pre><h1>Hello     Everyone</h1></pre>

Result:

html space between words on same line

Read the very simple balance 1 method  >> Click here