Home HTML Attributes codebase HTML codebase Attribute Definition
Definition and Usage The codebase attribute set a base URL for resources tied to an embedded <applet> or <object> — for example where to find .class files, JARs, or relative classid / data / archive paths.
For new work, put the resource URL in data and set type . Related obsolete attributes: classid , archive , codetype . Document-wide bases use <base> — a different feature.
Deprecated / Obsolete. Do not use codebase on <object>. The HTML living standard lists it as obsolete — prefer data and type. <applet> itself is obsolete. Learn it to read legacy markup, not to ship it.
Syntax
HTML Syntax <applet|object codebase=" URL ">
Value is a base URI. Relative resource paths were resolved against it (or against the document base if omitted).
Values
Attribute Values What authors historically put in codebase:
Value Description Try it Directory URL e.g. /applets/ or https://cdn.example/java/ Try itWith object Base for relative classid, data, or archive Try itModern alternative Omit codebase; use absolute or document-relative data + type Try it
Try it
Live Preview Toggle a legacy codebase value on a sample <object>. Modern browsers will not run applets/plugins — this demo only shows the attribute.
Code
HTML Examples Legacy snippets for study, plus the modern pattern. Use Try It Yourself for a live editor.
1. Applet (legacy) 2. Object (legacy) 3. Modern object Example 1 — Applet codebase (Legacy) Old pages pointed codebase at the folder holding the applet’s .class files.
<applet
code="Clock.class"
codebase="/applets/"
width="200"
height="200">
Your browser does not support Java applets.
</applet> Your browser does not support Java applets.
Fallback text — modern browsers do not run Java applets.
How It Works code named the main class file.codebase was the directory used to resolve that path.Fallback text appeared when applets were unavailable.Study only — never ship <applet> in new sites.Example 2 — Object codebase (Legacy) On <object>, codebase resolved relative data / plugin paths.
<object
codebase="/plugins/"
data="player.swf"
type="application/x-shockwave-flash"
width="320"
height="240">
<p>Plugin content is unavailable.</p>
</object> Plugin content is unavailable.
codebase on object is obsolete — browsers no longer run Flash plugins.
How It Works codebase set the base folder for relative resources.data named the file relative to that base (in legacy models).type hinted the MIME type for the plugin.Obsolete today — do not depend on this resolution.Example 3 — Modern Object Without codebase What the living standard recommends: put the full resource URL in data.
<object data="/media/report.pdf" type="application/pdf">
<p>
PDF preview is unavailable.
<a href="/media/report.pdf">Download the report</a>.
</p>
</object> How It Works No codebase — obsolete plugin base paths are omitted.data holds the resource URL directly.type describes the MIME type.Fallback keeps the page usable when embed fails. Edge Cases & Pitfalls Treat codebase as historical — applets and plugin base paths are gone from the modern web.
obsolete Not for new HTML Validators flag codebase on <object>. Firefox removed object codebase support (use data instead).
vs base Not the same as <base> <base href> affects the whole document. codebase applied only to one applet/object.
applet <applet> is obsoleteDo not revive Java applets. Prefer modern embeds or download links with fallback text.
param Named codebase parameter Old guidance: if a plugin needed a parameter named codebase, use <param> — still not a reason to ship plugins today.
family Same fate as classid / archive classid, archive, and codetype on object are obsolete too — same replacement: data + type.
Compatibility
Browser Support codebase is a legacy HTML attribute for applet/object resource bases. Engines may still parse it, but applets and plugins no longer run.
✓ Deprecated · Obsolete
codebase Recognized in old documents for compatibility. Modern browsers do not execute Java applets. Prefer a full URL in data on object.
Google Chrome Ignored for applets
Obsolete*
Mozilla Firefox Removed on object (142+)
Obsolete*
Apple Safari Ignored for applets
Obsolete*
Microsoft Edge Ignored for applets
Obsolete*
Opera Ignored for applets
Obsolete*
Samsung Internet Ignored for applets
Obsolete*
Internet Explorer Legacy applet/plugin era
Legacy* codebase Obsolete (do not use)
Bottom line: *Parsed for old pages at best — not recommended. Do not build new features on codebase, applets, or plugins.
Remember
Key Takeaways Role: base URL for applet/object resource paths.
Status: obsolete — keep for reading legacy HTML only.
Replace with: full URL in data + type on <object>.
≠ <base> — document base is a different element.
One line: learn codebase for old applet/object markup — ship data and type instead.
Frequently Asked Questions What does the HTML codebase attribute do? On applet and object, codebase set a base URL used to resolve relative paths for class files, JARs, classid, data, or archive resources.
Is codebase deprecated? Yes. The HTML living standard marks codebase on object as obsolete. The applet element is obsolete too. Prefer object with data and type.
Which elements used codebase? Historically applet and object. Both plugin/applet patterns are obsolete in modern HTML.
Is codebase the same as the base element? No. The base element sets a document-wide default base URL for links and resources. codebase applied only to one applet or object.
What replaces codebase today? Put a full (or document-relative) URL in data on object, and set type as needed. Do not rely on a separate codebase base path.
Should I still learn codebase? Yes for reading legacy Java applet and plugin pages. Do not use it in new projects.
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful
Helpful Share Copy link Suggestion