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

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.
Early layouts.
Do not use.
Historical only.
type, size.
Modern gap.
Layout spacing.
<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.
The <spacer> tag is not part of HTML5. Modern browsers do not render it as a spacing element. Use CSS instead.
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.
<spacer> in new projects. Replace it with margin, padding, gap, Flexbox, or CSS Grid.In its deprecated form, the spacer tag had a simple void-element syntax:
<spacer type="horizontal" width="20" height="20"><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.
| Topic | Details | Status |
|---|---|---|
<spacer> | Legacy gap element | Deprecated |
type | horizontal or vertical | Obsolete |
width / height | Spacer dimensions in pixels | Obsolete |
CSS margin | Space outside elements | Use this |
CSS gap | Flexbox / Grid spacing | Use this |
| Browser support | <spacer> element | 0% modern |
<spacer> vs CSS Spacing| Method | Purpose | Use today? |
|---|---|---|
<spacer> | Insert blank gap in markup | No — deprecated |
margin / padding | Space around or inside elements | Yes — standard |
Flexbox gap | Even spacing between flex items | Yes — standard |
CSS Grid gap | Row and column spacing in grids | Yes — standard |
The <spacer> tag supported two main attributes in legacy browsers:
type ObsoleteSpecified whether the spacer was horizontal or vertical.
type="horizontal"width ObsoleteWidth of the spacer in pixels (used for horizontal spacing).
width="20"height ObsoleteHeight of the spacer in pixels (used for vertical spacing).
height="20"Understand historical spacer use cases and practice the modern CSS replacements.
Modern spacing with CSS gap (the correct approach today):
In the past, <spacer> was commonly used for whitespace between elements and spacing within table cells. Neither pattern should be used today.
Historically, spacer created gaps between inline or block content to achieve specific layout designs:
<div>
<span>Left content</span>
<spacer type="horizontal" width="20" height="1">
<span>Right content</span>
</div>Legacy pages sometimes placed spacer inside table cells to adjust content alignment. Use CSS padding on td or th instead:
td {
padding: 12px 16px;
}For achieving spacing and layout in modern web development, use:
margin and padding — Create space around and inside elements.gap — Even spacing in responsive layouts.<style>
.row { display: flex; gap: 1.25rem; }
</style>
<div class="row">
<div>Item A</div>
<div>Item B</div>
<div>Item C</div>
</div>Use meaningful HTML elements without spacer hacks.
Set margin, padding, or gap in stylesheets.
Flexbox and Grid distribute space predictably across screen sizes.
CSS spacing adapts to any device without obsolete HTML elements.
Since the <spacer> tag is deprecated, it has 0% support for layout spacing in modern browsers. CSS spacing properties are universally supported.
Modern browsers ignore <spacer>. Use CSS margin, padding, and gap instead.
<spacer> element<spacer> not supported<spacer> not supported<spacer> not supported<spacer> not supported<spacer> not supportedNote: CSS margin, padding, and gap have ~99% global support.
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.
Given the deprecated status of the <spacer> tag, there are no best practices for its usage. Focus on modern CSS instead:
margin and padding for element spacinggap for layout rows and columns<spacer> element<spacer>Bookmark these so you never use obsolete spacing markup.
Do not use.
StatusLegacy tag.
HistoryCSS spacing.
AlternativeLayout rows.
ModernNo hacks.
A11yObsolete.
Compatibilitymargin, padding, or gap for spacing instead.type (horizontal/vertical), width, and height in legacy browsers.<spacer> element for layout spacing.Skip deprecated <spacer> markup. Practice Flexbox gap in the Try It editor.
6 people found this page helpful