Is There an HTML Space Tag?

A Quick Guide to Making and Controlling Spaces in HTML

Hamza TArkkol / Getty Images

It can be frustrating to add a string of spaces to your HTML only to have them disappear because of the way HTML handles spaces. An HTML space tag would be convenient for creating spaces.

However, there is no such thing as an HTML space tag. HTML compresses all space characters—tabs, spaces, and carriage returns—to one character. If you want to indent your paragraphs, you can’t simply type five spaces and then begin the text. That doesn't mean you don't have any control over spaces in your HTML. 

Alternatives to an HTML Space Tag

You have several options for creating and controlling white space on your webpages:

  • The HTML <br> tag is the line break tag. It produces a line break in text, like a carriage return on a typewriter or a return in a word processing program. You'd use it at the end of each line of an address, for example, to get the block format people are accustomed to seeing.
  • The <p> tag is a paragraph tag. It is applied to a section of text that is a block of text separated from nearby blocks of text by a blank space and/or first-line indent.
  • The <pre> tag is used with preformatted text. It instructs the browser that the text is to appear exactly as written in the HTML file including any spaces or blank lines. If you type five spaces inside <pre> tags, you get five spaces on the website.
  • Non-breaking space (&nbsp) is a space that does not break into a new line. Two words that are separated by a non-breaking space always appear on the same line.
  • CSS margin and padding properties

There are many HTML tags that you can use to modify your pages. With practice you should be able to get around the lack of an HTML space tag without too much trouble.