HTML archive Attribute

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Embedded Objects

Introduction

The archive attribute in HTML is used with the <object> element to specify a space-separated list of URLs of archives containing resources relevant to the object. This attribute is now largely obsolete, but it can still be found in older codebases. Understanding its purpose and usage can be helpful when maintaining or updating legacy HTML documents.

What You’ll Learn

01

Archive URLs

JAR and ZIP files.

02

object Element

Where archive applies.

03

Single URL

One archive file.

04

Multiple URLs

Space-separated list.

05

JavaScript

Set archive dynamically.

06

Legacy Code

Obsolete but useful.

Purpose of archive Attribute

The primary purpose of the archive attribute is to provide a list of URLs for archive files (like .zip or .jar files) that contain resources the object might need. This was particularly useful in the context of applets and other embedded objects that required additional resources bundled together.

⚠️
Largely Obsolete

Java applets and many embedded-object use cases are deprecated. You will rarely use archive in new projects, but it helps when reading older HTML.

📝 Syntax

Add archive to an <object> element with one or more space-separated archive URLs:

archive.html
<object data="myApp.jar" type="application/java-archive" archive="lib1.jar lib2.jar">
  <!-- Fallback content -->
</object>

Syntax Rules

  • Used on <object> (and historically <applet>).
  • Value is a space-separated list of URL strings.
  • Each URL should point to an archive file the object may load.
  • Always include fallback content inside <object> for unsupported browsers.

💎 Values

The archive attribute accepts a space-separated list of URL values. Each URL should point to an archive file containing resources for the object.

  • Single URLarchive="example1.jar" references one archive file.
  • Multiple URLsarchive="example1.jar example2.jar" lists several archives separated by spaces.
  • Relative or absolute — URLs may be paths on the same site or full https:// addresses.
archive-values.html
<!-- Single archive -->
<object archive="example1.jar" ...></object>

<!-- Multiple archives -->
<object archive="lib1.jar lib2.jar" ...></object>

⚡ Quick Reference

Use Casearchive ValueNotes
One library JARexample1.jarSingle URL
Multiple librarieslib1.jar lib2.jarSpace-separated
Main app + libsdata="myApp.jar" + archive="lib1.jar lib2.jar"data is primary; archive is extra
Applicable element<object>Also on deprecated <applet>
Modern statusObsoleteLegacy maintenance only

Applicable Elements

ElementSupported?Notes
<object>Yes (legacy)Primary element for archive
<applet>Yes (deprecated)Removed from HTML5; do not use
<img>Noarchive does not apply
<embed>NoUse object or modern APIs instead

Examples Gallery

Single archive URL, multiple archives, a complete object example, and dynamic JavaScript.

👀 Live Preview

Structure of an <object> with archive (fallback content shows in modern browsers):

archive="lib1.jar lib2.jar"

Fallback: Your browser does not support this embedded object.

Single URL Example

Specifies a single archive file:

index.html
<object data="example.jar" type="application/java-archive" archive="example1.jar">
  <!-- Fallback content -->
</object>
Try It Yourself

Multiple URLs Example

Specifies multiple archive files, separated by spaces:

index.html
<object data="example.jar" type="application/java-archive" archive="example1.jar example2.jar">
  <!-- Fallback content -->
</object>
Try It Yourself

Basic Example

Here’s a basic example of how the archive attribute is used in an HTML document:

index.html
<object data="myApp.jar" type="application/java-archive" archive="lib1.jar lib2.jar">
  <!-- Fallback content for browsers that do not support the object element -->
  Your browser does not support Java applets.
</object>
Try It Yourself

How It Works

In this example, the <object> element references an application archive (myApp.jar) and additional resource archives (lib1.jar and lib2.jar). The browser would load these together when Java applets were supported.

Dynamic Values with JavaScript

You can dynamically set or modify the archive attribute using JavaScript. This can be particularly useful when you need to update the resources for an object based on user interaction or other conditions. Here’s a brief example:

dynamic-archive.html
<object id="myObject" type="application/x-java-applet">
  Your browser does not support Java applets.
</object>

<script>
  document.getElementById("myObject").setAttribute("archive", "dynamicLib1.jar dynamicLib2.jar");
</script>
Try It Yourself

How It Works

In this script, the archive attribute is dynamically set to include dynamicLib1.jar and dynamicLib2.jar for an object element with the id myObject.

♿ Accessibility

  • Provide fallback content — Always include readable text inside <object> when the embedded resource cannot load.
  • Do not rely on applets — Java applets are inaccessible to most modern users; migrate to HTML, CSS, and JavaScript.
  • Describe embedded content — If you must embed media, offer equivalent content in plain HTML nearby.
  • Avoid plugin-only interfaces — Legacy objects often blocked keyboard and screen reader access.

🧠 How archive Works

1

Author lists archive URLs

One or more JAR/ZIP paths on the object element.

Markup
2

Browser loads object + archives

Plugin runtime fetches bundled resources (legacy behavior).

Load
3

Embedded object runs or fails

Success shows the applet; failure shows fallback HTML.

Render
=

Resources bundled for the object

Today, prefer modern web APIs instead of archive-based embedding.

Browser Support

The archive attribute was used with Java applets and embedded objects. Modern browsers no longer run Java applets, so this attribute is effectively obsolete for new development.

Obsolete · Legacy only

Historical embedded-object attribute

Understanding archive helps when reading or migrating old HTML—not when building new sites.

N/A Modern use
archive attribute Obsolete — legacy HTML

Bottom line: Do not use archive in new projects. Replace legacy applets with standard HTML, CSS, and JavaScript.

💡 Best Practices

✅ Do

  • Understand archive when maintaining legacy HTML
  • Ensure referenced archive files exist if legacy code must run
  • Include meaningful fallback content inside <object>
  • Migrate old applets to modern web technologies
  • Test legacy pages in controlled environments if still required

❌ Don’t

  • Use archive in new HTML5 documents
  • Depend on Java applets for critical functionality
  • Forget that browsers have removed NPAPI/plugin support
  • Leave broken object tags without fallback text
  • Assume space-separated URLs work like CSS class lists without testing

Conclusion

The archive attribute in HTML was designed to provide URLs of archive files containing resources for the <object> element. While it’s now considered obsolete, understanding its use can be important for maintaining and updating legacy HTML documents.

By utilizing JavaScript, you can also dynamically manage this attribute to adapt to changing resource requirements—though migrating away from applet-based embedding is the better long-term approach.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about archive

Bookmark these when you encounter legacy embedded objects.

5
Core concepts
📄 02

object Element

Primary target.

Scope
🔗 03

Space-Separated

Multiple URLs.

Syntax
⚙️ 04

JavaScript

setAttribute()

Dynamic
05

Obsolete

Legacy only.

Status

❓ Frequently Asked Questions

It lists URLs of archive files (such as JAR files) that contain resources an embedded object needs.
The <object> element. It was also used on the deprecated <applet> element.
No. Java applets and plugin-based embedding are obsolete. Use modern HTML, CSS, and JavaScript instead.
Separate URLs with spaces: archive="lib1.jar lib2.jar".
Yes. Use element.setAttribute("archive", "file1.jar file2.jar") at runtime.
data points to the primary object resource. archive lists additional supporting archive files.

Understand legacy HTML embedding

Practice the archive attribute with single, multiple, and dynamic examples in the Try It editor.

Try basic example →

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.

5 people found this page helpful