Older websites sometimes contain HTML tags that no longer belong in modern pages. The <command> element is one of them. Represented a user command in old HTML proposals.
It is useful to recognize legacy HTML when maintaining an existing site, but beginners should usually learn the modern pattern first. Browsers may still show something for obsolete tags, but that does not make those tags a safe long-term choice.
What older code was trying to do
Represented a user command in old HTML proposals. The problem with carrying that idea forward is that modern browser features, accessibility expectations, security rules, or CSS provide a different and more dependable solution.
A modern alternative
<button type="button" id="print-page">Print this page</button>
<script>
document.querySelector('#print-page').addEventListener('click', () => window.print());
</script>
Why the replacement is better
Use a native button for actions; the old command element is not a modern interoperable feature.
In the example, look for standard HTML elements that communicate a meaningful page structure or action. Styling belongs in CSS where appropriate. Interactive actions belong in real controls backed by JavaScript or a server, not in unsupported legacy elements.
How to update an older page
- Find the old element and identify exactly what information or behavior people depend on.
- Choose native modern HTML first; use CSS for presentation and JavaScript only when real behavior is needed.
- Replace one region, then check that text, links, keyboard navigation, and resource loading still work.
- Validate the updated markup and test in more than one browser if the feature is important.
Try it yourself
Create a small legacy HTML fragment in a disposable practice file. Write a modern equivalent beneath it, then compare the result in a browser. Do not publish the old fragment as recommended code.
Common Beginner Mistakes
- Use a native button for actions; the old command element is not a modern interoperable feature.
- Copying old code because it appears to work in one browser.
- Replacing the old tag visually but forgetting its information or accessibility purpose.
Key Takeaways
<command>belongs to historical rather than recommended modern HTML.- Use a native button for actions; the old command element is not a modern interoperable feature.
- Preserve meaning and usability when migrating legacy documents.