Skip to main content

4 Ways to Insert Spaces in HTML

As any web developer knows, HTML is the backbone of the internet. The language is responsible for everything from the structure of web pages to the layout of text and images. While HTML is a powerful tool, it can also be quite challenging to master. One common issue that developers face is how to insert multiple spaces in HTML.

Space key

If you only insert 1 blank space, it is easy. You can just type a ” ” by pressing the Space key on your keyboard. If you need more than 1, some HTML entities are required to be used.

There are a few different ways to do this, and the approach that you take will often depend on your specific needs.

<span>One of the most basic things 
you'll need to know is how to insert spaces in HTML.</span>


If you want to control the number of spaces between 2 letters, this &nbsp; entity can add a single space between two elements. This code will tell the browser to insert a non-breaking space between the two elements.

If you want to add more than 1, just insert a number of the entity.

There is an alternative to &nbsp, which is &#160;. Web browsers understand both of them.

<p>HTML&nbsp;is&nbsp;a&nbsp;programming language 
used to create websites.</p>


This entity adds 2 spaces between 2 words or elements.

<p>HTML consists of a&ensp;series of tags that define 
the structure of a web page.</p>


This &emsp; entity adds 4 spaces between 2 elements or words.

<p>With HTML, you can create&emsp;structural elements like headings, paragraphs, 
and list items, as well as insert images and other media.</p>

By continuing to use the site, you agree to the use of cookies.