HTML codebase Attribute

The obsolete HTML codebase attribute was historically used to specify a base URL for files and resources associated with an embedded applet or object.

Historical Syntax

The codebase attribute specified a location that could be used as the base URL for related resources:

<applet code="Example.class" codebase="/applets/" width="400" height="300">
  Alternative content
</applet>

In this example, the browser could use /applets/ as the base location when resolving the Java class specified by the code attribute and other applet-related resources.

Historical Elements

The codebase attribute was historically associated with the <applet> and <object> elements.

Element Historical Purpose
<applet> Specified the base URL used to locate Java applet classes and related resources.
<object> Specified a base URL used when resolving resources associated with an embedded object.

Historical Use

The codebase attribute allowed resources associated with an applet or object to be stored in a location different from the HTML document. Relative resource references could then be resolved using the location specified by codebase.

For Java applets, codebase was commonly used together with attributes such as code and archive. This allowed an applet's compiled classes and supporting files to be organized separately from the webpage containing the applet.

The attribute was also part of older object embedding mechanisms that depended on external plug-ins or other technologies that are no longer used by modern browsers.

Why It Became Obsolete

The codebase attribute was closely associated with older applet, object, and plug-in technologies. Java applets and many traditional browser plug-ins are no longer supported by modern browsers.

Modern HTML elements provide their own attributes for identifying resources. URLs can be absolute or relative and are resolved according to standard URL rules, eliminating the need for an element-specific codebase mechanism.

Modern Alternative

There is no single direct replacement for the obsolete codebase attribute. Modern HTML elements use attributes appropriate for the resource being loaded.

For example, the modern <object> element uses the data attribute to specify its resource:

<object data="/documents/example.pdf" type="application/pdf">
  <p>Your browser cannot display the PDF document.</p>
</object>

Other HTML elements use their own resource attributes:

<img src="/images/photo.jpg" alt="Example photo">

<video controls>
  <source src="/media/video.mp4" type="video/mp4">
</video>

<script src="/js/example.js"></script>

These resources can use relative or absolute URLs without an obsolete codebase attribute. If a document-wide base URL is genuinely required for relative URLs, HTML provides the <base> element in the document <head>, but it affects relative URLs throughout the document and is not a direct replacement for the historical codebase attribute.

Legacy Browser Support

The codebase attribute was recognized in older browsers as part of applet and object embedding systems. Its behavior depended on support for the associated embedded content and, in many cases, external browser plug-ins.

Modern browsers should not be expected to reproduce legacy applet or plug-in behavior that depended on codebase. Existing content that relies on these technologies generally needs to be updated to use current HTML and web platform features.

For additional information about historical browser compatibility, visit Can I Use? . Search for the HTML element or attribute you want to check. Search results can include related HTML features, element attributes, APIs, and other technologies, so select the result that most closely matches the legacy feature you are researching.

Other obsolete HTML attributes historically associated with applets, objects, and embedded resources include:

  • code - Historically used to specify the compiled Java class for an applet.
  • archive - Historically used to identify archives containing classes and related resources.
  • codetype - Historically used to specify the content type of code associated with an object.
  • classid - Historically used to identify an implementation for an embedded object.

Specifications

The codebase attribute is obsolete in modern HTML and should not be used to locate resources for embedded content. See the WHATWG HTML Living Standard for information about obsolete and non-conforming features.