Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

html
blank space

How to add a space in HTML

Educative Answers Team
svg viewer

HTML Entities

Some characters are reserved for coding in HTML (ex: <, >, "). If these characters are to be included in your text, it can’t be written like the rest of it. HTML Entities allow us to add the characters reserved for coding HTML into our text. To add an HTML Entity, you need to write a & followed by the characters code.

For example, to add a less than sign (<), you can write &lt or &#60. Here lt is the Entity Name and #60 is the Entity Number.

CAUTION: Entity names are case sensitive.

Similarly, there is an Entity to add extra space: &npsp (non-breaking space) or &#160.

Adding an extra space in HTML

Look at the sentence below:

No matter how many physical spaces we add, HTML always renders it as a single space.

There are two ways to add an extra space :

  1. Use the HTML Entity &nbsp/&#160.
  2. Use the preformatted tag <pre>. As the name implies, the text is displayed as it is coded.

NOTE: The <pre> tag displays text with a fixed-width font (usually Courier).

RELATED TAGS

html
blank space
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring