HTML <listing> Tag

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Obsolete · Legacy Reference

What You’ll Learn

By the end of this tutorial, you’ll understand what <listing> was for, why it is obsolete, and which modern tags to use instead.

01

Legacy Purpose

Preformatted text and code in monospaced font.

02

Obsolete Status

Deprecated in HTML 4, removed from HTML5.

03

Not a List Tag

Despite the name, it never created ul/ol lists.

04

Use <pre>

Modern replacement for preformatted blocks.

05

Use <code>

Inline snippets and combined code blocks.

06

Migration Path

Replace listing in legacy code with pre + code.

What Is the <listing> Tag?

The listing element (<listing>) was an early HTML tag for displaying preformatted text — especially code listings. Text inside listing was rendered in a monospaced font with whitespace and line breaks preserved, similar to how <pre> works today.

⚠️
Obsolete in HTML5 — Use <pre> and <code>

Do not use <listing> in new projects. It was deprecated in HTML 4.01 and removed from HTML5. Some browsers still render it like <pre>, but behavior is not guaranteed.

The name listing refers to a “code listing” or text listing — not an HTML list like <ul> or <ol>. For actual lists, use <li> inside list containers.

📝 Syntax

Historically, listing wrapped preformatted content with opening and closing tags:

syntax.html
<listing>
Your preformatted text or code here.
</listing>

Syntax Rules

  • Requires both opening and closing tags — not a void element.
  • Preserved whitespace and line breaks inside the element.
  • No standard attributes were defined for listing.
  • Do not use in new HTML — use <pre> instead.

⚡ Quick Reference

PatternCode SnippetStatus
Legacy listing<listing>code</listing>Obsolete
Preformatted block<pre>code</pre>Modern replacement
Inline code<code>fn()</code>Modern replacement
Code block<pre><code>...</code></pre>Best practice
Actual lists<ul><li>...</li></ul>Use for lists, not listing
AttributesNoneN/A

⚖️ <listing> vs <pre>

Feature<listing><pre>
HTML5 statusObsoleteStandard
PurposeLegacy preformatted textPreformatted text blocks
WhitespacePreservedPreserved
Browser supportPartial / legacyUniversal
Use today?NoYes

⚖️ <listing> vs List Tags

Do not confuse listing with list elements — they are unrelated despite similar names:

TagPurposeExample use
<listing>Preformatted code/text (obsolete)Legacy code display
<ul> / <ol>Structured listsNavigation, steps, features
<li>Single list itemEach bullet or numbered entry
<dl>Description listTerms and definitions

🧰 Attributes

The <listing> element did not define any specific attributes. Only global attributes applied in theory, but the entire element is obsolete:

None Obsolete

Listing had no dedicated attributes. It simply wrapped preformatted content.

<listing>...</listing>
Global attrs Legacy

Attributes like class or id may have worked in old browsers but are irrelevant today.

class="legacy"

For modern code blocks, style <pre> and <code> with CSS instead.

Examples Gallery

Legacy listing usage and the modern <pre> and <code> replacements you should use instead.

Live Preview

Modern <pre><code> block (what you should use today):

function exampleFunction() {
    return "Hello, World!";
}

Historical listing Usage

In the past, listing displayed code blocks with fixed-width formatting. Do not use this in new projects.

legacy-listing.html
<listing>
function exampleFunction() {
    return "Hello, World!";
}
</listing>

📚 Modern Replacements

Replace every <listing> in legacy code with <pre> for blocks, <code> for inline snippets, or <pre><code> together for semantic code listings.

pre Tag Replacement

Use <pre> for preformatted text blocks that preserve whitespace.

pre.html
<pre>
function exampleFunction() {
    return "Hello, World!";
}
</pre>
Try It Yourself

Inline code Tag

For short code mentions within a sentence, use <code>.

inline-code.html
<p>Use the <code>console.log()</code> function to print messages.</p>
Try It Yourself

Combined pre + code

Best practice for code blocks: nest <code> inside <pre> for semantics and styling.

pre-code.html
<pre>
  <code>
function exampleFunction() {
    return "Hello, World!";
}
  </code>
</pre>

Styling Code Blocks with CSS

Style modern <pre> and <code> replacements instead of obsolete listing:

pre Block formatting
code Inline monospace
white-space Preserve spacing
overflow-x Scroll long lines
code-block.css
pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
}

code {
  font-family: ui-monospace, monospace;
}

p code {
  background: #f1f5f9;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

Styled pre + code block

♿ Accessibility

Modern code presentation is more accessible than legacy listing:

  • Use semantic <code> — screen readers can identify inline code snippets.
  • Wrap blocks in <pre><code> — clearer structure than obsolete listing.
  • Ensure sufficient contrast — style code blocks with readable foreground and background colors.
  • Allow horizontal scroll — use overflow-x: auto so long lines do not break layout on small screens.

🧠 How <listing> Worked (Legacy)

1

Author wrapped text in listing

Code or preformatted text placed inside <listing> tags.

Legacy markup
2

Browser used monospace font

Whitespace and line breaks were preserved like a typewriter layout.

Rendering
3

HTML5 removed listing

Spec dropped the element; browsers map it to pre-like rendering for compatibility.

Obsolete
=

Use pre + code today

Modern tags give the same visual result with standard HTML5 semantics and full browser support.

Legacy Browser Support

The <listing> element is obsolete. Browsers may still render it similarly to <pre>, but it is not part of HTML5 and should not be used in production.

Obsolete · Use pre + code

Legacy rendering only

Most browsers treat listing like pre for backward compatibility, but the element is removed from the HTML5 specification.

95% Legacy reference support
Google Chrome Rendered as pre-like · Not in HTML5
Legacy only
Mozilla Firefox Rendered as pre-like · Not in HTML5
Legacy only
Apple Safari Rendered as pre-like · Not in HTML5
Legacy only
Microsoft Edge Rendered as pre-like · Not in HTML5
Legacy only
Internet Explorer Legacy support · Obsolete
Legacy only
Opera Rendered as pre-like · Not in HTML5
Legacy only
<listing> tag 95% legacy reference

Bottom line: Do not use <listing> in new code. Use <pre> and <code> for full HTML5 compliance and consistent behavior.

Conclusion

The <listing> tag is a relic of early HTML for displaying preformatted text and code. It is obsolete in HTML5 and must not appear in new projects.

Replace every listing with <pre> for blocks, <code> for inline snippets, or both together for semantic code listings. For actual content lists, use <ul>, <ol>, and <li>.

💡 Best Practices

✅ Do

  • Use <pre><code> for code blocks
  • Use <code> for inline code mentions
  • Style code blocks with CSS for contrast and readability
  • Use <ul>/<ol> for actual lists

❌ Don’t

  • Use <listing> in new HTML documents
  • Assume listing creates bullet or numbered lists
  • Depend on legacy browser mapping to pre
  • Skip semantic code tags for plain divs

Key Takeaways

Knowledge Unlocked

Six truths every developer should know about <listing>

Bookmark these so you never confuse legacy listing with modern list or code tags.

6
Core concepts
🚫 02

Obsolete

Removed from HTML5 — do not use.

Status
⚖️ 03

Not a List

Name refers to code listings, not ul/ol.

Comparison
💻 04

Use pre

Modern block replacement.

Replacement
📝 05

Use code

Inline and nested code snippets.

Replacement
06

Legacy Only

Browsers may map it to pre-like output.

Compatibility

❓ Frequently Asked Questions

It displayed preformatted text and code in a monospaced font, preserving whitespace and line breaks.
No. It is obsolete and removed from the HTML5 specification. Use <pre> and <code> instead.
No. Despite the name, listing was never a list container. Use ul, ol, and li for lists.
<pre> for blocks, <code> for inline snippets, and <pre><code> together for code listings.
Some browsers render it like <pre> for backward compatibility, but it is not standard HTML5.
No. Learn it only to read legacy code. Always use pre and code in new projects.

Practice Modern Code Tags

Try pre, code, and pre+code replacements in the interactive editor.

Try It Yourself →

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