HTML <spacer> Tag

Beginner
5 min read
Updated: Nov 2026
3 examples
Live preview

Definition and Usage

The <spacer> element was a Netscape-only way to insert empty horizontal, vertical, or block gaps — a substitute for single-pixel spacer GIFs before CSS layout was common.

Study it only as web history. For real spacing today, use margin, padding, or gap with display: flex / grid. Prefer meaningful structure ( <p>, <div>, sections) over empty layout tags.

Obsolete & non-standard.

Never part of HTML standards. Listed in the WHATWG obsolete elements. No major browser applies spacing from <spacer> today.

Use instead.

CSS margin / padding for box spacing; gap for flex and grid. Avoid empty <div>s when a margin on existing content is enough.

HTML Syntax

syntax.html
<spacer type=" horizontal" size="10">

Historical markup was empty (no useful content). Modern engines treat it as an unknown element — no gap appears.

Attributes

Historical attributes (all ineffective in current browsers):

AttributeDescriptionTry it
typehorizontal, vertical, or blockTry it
sizePixel length for horizontal or verticalTry it
width / heightPixel box size when type="block"Legacy only
alignleft, right, or center (block spacers)Deprecated style
Modern CSSmargin, padding, or gap replace all of the aboveTry it

Global Attributes

The <spacer> tag also supports the Global Attributes in HTML — they do not restore spacing behavior.

Live Preview

Compare ignored legacy markup with working CSS spacing.

Legacy mode shows no intentional gap. CSS modes demonstrate real spacing.

Preview
LeftRight — modern browsers ignore the spacer.

Legacy — no spacing effect from <spacer>.

HTML Examples

Historical markup for study, then CSS replacements. Use Try It Yourself for a live editor.

Example 1 — Legacy <spacer> Markup

Historical syntax only. Modern browsers do not insert a gap.

HTML
<span>Left</span>
<spacer type="horizontal" size="40">
<span>Right</span>

<spacer type="block" width="100" height="24">
Try It Yourself

How It Works

  1. Old Netscape read type and size/width/height.
  2. Horizontal meant a sideways gap; vertical stacked; block was a rectangle.
  3. Today: unknown element — text may sit adjacent with only normal whitespace.
  4. Do not ship this in new HTML.

Example 2 — Replace with CSS margin

Space around content with margin instead of an empty tag.

HTML
<p class="first">First block</p>
<p class="second">Second block with top margin</p>

<!-- CSS: .first { margin: 0; } .second { margin-top: 1.5rem; } -->
Try It Yourself

How It Works

  1. Keep real content elements (here, paragraphs).
  2. Set margin on the element that needs distance from its neighbor.
  3. Prefer a stylesheet over inline styles in production pages.
  4. Use padding when the space belongs inside a box, not between boxes.

Example 3 — Replace with Flex gap

Even spacing between siblings without spacer nodes.

HTML
<div class="row">
  <span>Left</span>
  <span>Right</span>
</div>

<!-- In CSS: .row { display: flex; gap: 2.5rem; } -->
Try It Yourself

How It Works

  1. Wrap siblings in a flex (or grid) container.
  2. Set gap for consistent space between items.
  3. No empty <spacer> (or empty div) required between children.
  4. Same idea for grids with display: grid and gap.

Edge Cases & Pitfalls

Most “bugs” are expecting Netscape-era gaps in modern engines.

obsolete

Never use in new pages

Validators and the HTML Living Standard treat spacer as author-forbidden. Replace on sight.

silent

Looks like markup, does nothing

Unknown elements may still appear in the DOM inspector while producing zero layout effect — easy to miss in reviews.

a11y

Empty tags are not structure

Spacing is presentation. Use headings, lists, and landmarks for meaning; CSS for distance.

migration

Do not swap for empty divs

A bare <div style="height:40px"> repeats the same anti-pattern. Prefer margin/gap on real content.

history

Not the same as CSS spacer utilities

Framework “spacer” classes are CSS helpers. The HTML <spacer> element is a dead Netscape tag.

Browser Support

The <spacer> element is obsolete and unsupported. Spacing belongs to CSS.

✓ Obsolete · Non-standard

<spacer>

Netscape-only in the 1990s. Never standardized. Firefox removed it early; Chrome, Safari, Edge, and Opera do not implement spacer layout. Use margin, padding, or gap.

0% Modern support for &lt;spacer&gt;
Google Chrome Never
Unsupported
Mozilla Firefox Removed (legacy)
Unsupported
Apple Safari Never
Unsupported
Microsoft Edge Never
Unsupported
Opera Never
Unsupported
Samsung Internet Never
Unsupported
<spacer> element Unsupported

Bottom line: Do not use <spacer>. CSS margin, padding, and gap work everywhere that matters.

Key Takeaways

  • Status: <spacer> is obsolete Netscape markup — never use it.
  • Replace with: margin, padding, or flex/grid gap.
  • Attributes: type, size, width, height, align are historical only.
  • Structure first: space real content; avoid empty layout tags.

One line: skip <spacer>; control distance with CSS on meaningful HTML.

Default CSS Settings

Unknown elements like obsolete spacer typically display inline with no special size:

default.css
spacer {
  display: inline;
}

There is no user-agent stylesheet that recreates Netscape type/size gaps.

Frequently Asked Questions

Netscape introduced spacer to insert empty horizontal, vertical, or block gaps without a spacer GIF image. It was a proprietary layout helper from the mid-1990s.
No. It was never standardized. Firefox (Netscape’s successor) dropped it long ago, and current browsers ignore it for spacing.
Only as an obsolete element authors must not use. The WHATWG obsolete section says to use appropriate elements or CSS instead.
Use CSS margin or padding for spacing around elements, and gap for flex or grid layouts. Prefer real structure (paragraphs, lists, sections) over empty spacer tags.
type was horizontal, vertical, or block. size set pixel length for horizontal/vertical. For block, width and height set the empty rectangle; align could be left, right, or center.
You may see it in very old pages or archives. Recognizing it helps you replace dead markup with CSS quickly.

Next: span

Wrap inline text for styling or scripting without changing meaning.

span tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful