W3docs

HTML <spacer> Tag

The HTML <spacer> tag is an obsolete Netscape element that no modern browser supports. Use CSS margin, padding, or gap instead.

The HTML <spacer> tag is an obsolete element that no modern browser supports. Do not use it. If you need to add empty space between elements on a web page, reach for CSS instead — the margin, padding, and gap properties give you full, reliable control across every browser.

This page explains what <spacer> was, why it disappeared, and — most importantly — the modern CSS techniques you should use in its place.

Danger

The <spacer> tag was never part of any official HTML standard. It has been non-functional in every major browser for over two decades. Any <spacer> element in your markup is silently ignored. Use CSS margin, padding, or gap instead.

A brief history

In the mid-1990s, before CSS was widely available, web authors had no standard way to control spacing. A common hack was to insert a transparent 1×1 pixel image (the "spacer GIF") and stretch it with width and height attributes to push content around.

To make this less clumsy, Netscape introduced the proprietary <spacer> element in Netscape Navigator in the mid-1990s. It let you add horizontal, vertical, or block-shaped empty space without loading an image. However:

  • It was a Netscape-only extension — Internet Explorer and other browsers never implemented it.
  • It was never added to the HTML specification.
  • Once CSS matured, it became completely unnecessary.

As a result, <spacer> was abandoned. Today it is listed among the obsolete and deprecated HTML tags and is ignored by all browsers.

The old (non-functional) syntax

For historical reference only, this is how <spacer> was written. The tag was empty, so it had no closing tag. This code does nothing in any current browser — it is shown purely to illustrate the legacy syntax.

<!-- OBSOLETE — does not work in any modern browser. Do not use. -->
<p>
  Some text
  <spacer type="horizontal" size="100">
  more text after a horizontal gap.
</p>

<spacer type="block" width="100" height="50">

The modern way: use CSS

CSS replaces every use case the <spacer> tag tried to cover, and works everywhere.

Horizontal and vertical space with margin / padding

Use margin to add space outside an element and padding to add space inside it. The example below adds horizontal space between two words and vertical space below a paragraph:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      .gap-right {
        /* horizontal space after the word */
        margin-right: 100px;
      }
      .spaced {
        /* vertical space below the paragraph */
        margin-bottom: 40px;
      }
      .padded {
        /* internal space on all sides */
        padding: 20px;
        background-color: #d4f0f0;
      }
    </style>
  </head>
  <body>
    <p>
      <span class="gap-right">Start</span>End
    </p>
    <p class="spaced">This paragraph has 40px of space below it.</p>
    <p class="padded">This paragraph has 20px of padding inside it.</p>
  </body>
</html>
Result

Even spacing between items with gap

When you arrange items with Flexbox or CSS Grid, the gap property adds consistent space between them without touching the items' own margins:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      .row {
        display: flex;
        gap: 24px; /* space between every item */
      }
      .row > div {
        padding: 10px 16px;
        background-color: #d4f0f0;
      }
    </style>
  </head>
  <body>
    <div class="row">
      <div>One</div>
      <div>Two</div>
      <div>Three</div>
    </div>
  </body>
</html>
Result

Other ways to add space

Depending on what you need, these standard HTML and CSS options also help control blank space:

  • The <p> tag creates a paragraph break with default spacing above and below.
  • The <br> tag inserts a single line break.
  • The <pre> tag preserves preformatted text, so blank lines and spaces appear exactly as written in the HTML.
  • The &nbsp; character entity creates a non-breaking space.
  • The &#9; character is a tab. It usually needs surrounding text or CSS such as white-space: pre to render visibly.

Legacy attributes (for reference)

These attributes belonged to the obsolete <spacer> tag. They are listed only so you can recognize them in old markup — none of them function today.

AttributeValueDescription
alignleft, right, centerAlignment of a block-type spacer.
sizenumber of pixelsSize of the empty space for horizontal or vertical spacers.
widthnumber of pixelsWidth of the empty space for a block-type spacer.
heightnumber of pixelsHeight of the empty space for a block-type spacer.
typehorizontal, vertical, blockDirection/shape of the spacer.

Practice

Practice
Which statement about the HTML spacer tag is correct?
Which statement about the HTML spacer tag is correct?
Was this page helpful?