HTML <spacer> Tag

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 2 Examples
Legacy HTML

What You’ll Learn

The <spacer> tag once added gaps in early web layouts. This guide explains its deprecated status, historical syntax, and modern CSS spacing techniques beginners should use instead.

01

History

Early layouts.

02

Deprecated

Do not use.

03

Syntax

Historical only.

04

Attributes

type, size.

05

CSS margin

Modern gap.

06

Flex/Grid

Layout spacing.

What Is the <spacer> Tag?

The <spacer> tag was historically used to create empty spaces or gaps between elements on a webpage. It was particularly popular in the early days of HTML for layout purposes, especially in Netscape-based designs.

🚫
Deprecated — Not for Modern HTML

The <spacer> tag is not part of HTML5. Modern browsers do not render it as a spacing element. Use CSS instead.

🚫 Deprecated Status

As of HTML5, the <spacer> tag has been deprecated and is no longer recommended for use in modern web development. Developers are encouraged to use CSS for spacing and layout, which provides more flexibility and control.

Do not use <spacer> in new projects. Replace it with margin, padding, gap, Flexbox, or CSS Grid.

📝 Syntax

In its deprecated form, the spacer tag had a simple void-element syntax:

index.html
<spacer type="horizontal" width="20" height="20">

Historical Inline Use

historical-spacer.html
<p>
  Left content
  <spacer type="horizontal" width="20" height="1">
  Right content
</p>

This syntax should be avoided. See the Alternatives section for modern spacing.

⚡ Quick Reference

TopicDetailsStatus
<spacer>Legacy gap elementDeprecated
typehorizontal or verticalObsolete
width / heightSpacer dimensions in pixelsObsolete
CSS marginSpace outside elementsUse this
CSS gapFlexbox / Grid spacingUse this
Browser support<spacer> element0% modern

⚖️ <spacer> vs CSS Spacing

MethodPurposeUse today?
<spacer>Insert blank gap in markupNo — deprecated
margin / paddingSpace around or inside elementsYes — standard
Flexbox gapEven spacing between flex itemsYes — standard
CSS Grid gapRow and column spacing in gridsYes — standard

🧰 Attributes

The <spacer> tag supported two main attributes in legacy browsers:

type Obsolete

Specified whether the spacer was horizontal or vertical.

type="horizontal"
width Obsolete

Width of the spacer in pixels (used for horizontal spacing).

width="20"
height Obsolete

Height of the spacer in pixels (used for vertical spacing).

height="20"

Examples Gallery

Understand historical spacer use cases and practice the modern CSS replacements.

👀 Live Preview

Modern spacing with CSS gap (the correct approach today):

Item A Item B Item C

📚 Common Use Cases

In the past, <spacer> was commonly used for whitespace between elements and spacing within table cells. Neither pattern should be used today.

Whitespace Between Elements

Historically, spacer created gaps between inline or block content to achieve specific layout designs:

historical-whitespace.html
<div>
  <span>Left content</span>
  <spacer type="horizontal" width="20" height="1">
  <span>Right content</span>
</div>
Try It Yourself

Spacing Within Table Cells

Legacy pages sometimes placed spacer inside table cells to adjust content alignment. Use CSS padding on td or th instead:

table-cell-padding.css
td {
  padding: 12px 16px;
}

Alternatives — Modern CSS Spacing

For achieving spacing and layout in modern web development, use:

  • CSS margin and padding — Create space around and inside elements.
  • Flexbox or CSS Grid gap — Even spacing in responsive layouts.
  • Semantic HTML — Structure content without presentational spacer elements.
modern-spacing.html
<style>
  .row { display: flex; gap: 1.25rem; }
</style>
<div class="row">
  <div>Item A</div>
  <div>Item B</div>
  <div>Item C</div>
</div>
Try It Yourself

♿ Accessibility

  • Do not use spacer markup — Empty presentational elements add noise for assistive technology without semantic value.
  • Use CSS for visual spacing — Screen readers ignore margin and padding, keeping content structure clean.
  • Prefer semantic structure — Use headings, lists, and sections instead of spacer hacks for layout.
  • Maintain readable spacing — Adequate padding improves touch targets and readability on mobile.

🧠 How Modern Spacing Works

1

Structure content semantically

Use meaningful HTML elements without spacer hacks.

HTML
2

Apply CSS spacing

Set margin, padding, or gap in stylesheets.

CSS
3

Browser renders layout

Flexbox and Grid distribute space predictably across screen sizes.

Layout
=

Maintainable, responsive spacing

CSS spacing adapts to any device without obsolete HTML elements.

Browser Support

Since the <spacer> tag is deprecated, it has 0% support for layout spacing in modern browsers. CSS spacing properties are universally supported.

🚫 Deprecated · Legacy Element

Do not use the spacer tag

Modern browsers ignore <spacer>. Use CSS margin, padding, and gap instead.

0% <spacer> element
Google Chrome <spacer> not supported
Not supported
Mozilla Firefox <spacer> not supported
Not supported
Apple Safari <spacer> not supported
Not supported
Microsoft Edge <spacer> not supported
Not supported
Internet Explorer Legacy only · EOL
Not supported
Opera <spacer> not supported
Not supported
<spacer> HTML element 0% — deprecated

Note: CSS margin, padding, and gap have ~99% global support.

Conclusion

While the <spacer> tag served its purpose in the early days of HTML, its deprecated status signifies the evolution of web development practices. Embracing modern CSS techniques and semantic HTML elements ensures better compatibility, maintainability, and accessibility in your web projects.

💡 Best Practices

Given the deprecated status of the <spacer> tag, there are no best practices for its usage. Focus on modern CSS instead:

✅ Do

  • Use margin and padding for element spacing
  • Use Flexbox or Grid gap for layout rows and columns
  • Keep spacing in CSS stylesheets, not HTML markup
  • Use semantic HTML for document structure

❌ Don’t

  • Use the deprecated <spacer> element
  • Insert empty elements purely for visual gaps
  • Rely on table cell spacer hacks for alignment
  • Mix legacy spacer markup into new projects

Key Takeaways

Knowledge Unlocked

Six truths every developer should know about <spacer>

Bookmark these so you never use obsolete spacing markup.

6
Core concepts
📜 02

Netscape era

Legacy tag.

History
📐 03

margin/padding

CSS spacing.

Alternative
04

Flex/Grid gap

Layout rows.

Modern
05

Semantic HTML

No hacks.

A11y
🔴 06

0% Support

Obsolete.

Compatibility

❓ Frequently Asked Questions

Historically it inserted horizontal or vertical gaps in early layouts. It is now deprecated and unsupported.
No. Use CSS margin, padding, or gap for spacing instead.
CSS margin and padding for element spacing, Flexbox/Grid gap for layouts, and semantic HTML for structure.
type (horizontal/vertical), width, and height in legacy browsers.
No. Modern browsers do not support the <spacer> element for layout spacing.

Space layouts with CSS

Skip deprecated <spacer> markup. Practice Flexbox gap in the Try It editor.

Try modern spacing →

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.

6 people found this page helpful