The border attribute set a border width in pixels on legacy elements — mainly <table>, <img>, and <object>. On a table it defined the size of the outer frame; 0 meant no frame.
Do not use it in new pages. MDN recommends the CSS border property (and related properties like border-collapse) instead. For images, the HTML living standard says authors should not specify border; if it is present, its value must be "0".
Deprecated / legacy.
Presentational HTML. Documented so you can read old markup and migrate tables and images to CSS — not for new designs.
Browsers may still draw it.
Compatibility rendering is common, which is why old border="1" tables still look bordered. Prefer CSS so width, style, and color stay under your control.
Syntax
HTML Syntax
syntax.html
<table|img|object border="pixels">
pixels is a non-negative integer (no unit). Historical form only.
Values
Attribute Values
Common legacy values and the modern CSS approach:
Value
Description
Try it
1, 2, …
Border width in pixels (table frame / image border)
Try It Yourself applies a CSS border class to the image.
How It Works
Spec guidance: do not put border on <img>; if you must for old tools, only border="0" is conforming.
Draw a frame with CSS — width, style, and color in one place.
Always keep alt for accessibility (unrelated to border, required for images).
Same idea for <object> — use CSS, not the HTML attribute.
Edge Cases & Pitfalls
Most issues come from expecting the attribute to style a full CSS grid.
deprecated
Not for new HTML
Replace with CSS when you edit a page. Keep presentational attributes out of components and templates.
img
Non-zero img border is non-conforming
If border appears on an image, the living standard requires the value 0. Use CSS for visible frames.
tables
Outer frame ≠ full grid
For lines around every cell, style th/td in CSS. Related legacy attributes rules and frame are also obsolete.
units
No px in the attribute
Write border="2", not border="2px". CSS uses units; the HTML attribute does not.
cascade
CSS can override legacy borders
A stylesheet may hide or restyle an old HTML border. Pick one approach — CSS — so behavior is predictable.
Compatibility
Browser Support
border is a deprecated HTML attribute on table, img, and object. Many browsers still render it for compatibility.
✓ Deprecated · Legacy only
border
Still drawn in modern browsers for old pages. Not recommended for new work — use the CSS border property.
0%Recommended for new work
Google ChromeStill paints · legacy
Legacy only
Mozilla FirefoxStill paints · legacy
Legacy only
Apple SafariStill paints · legacy
Legacy only
Microsoft EdgeStill paints · legacy
Legacy only
OperaStill paints · legacy
Legacy only
Internet ExplorerLegacy support
Legacy only
borderDeprecated — use CSS
Bottom line: Expect old tables and images to keep their HTML borders. Write new borders with CSS.
Remember
Key Takeaways
Was: pixel border width on table, img, and object.
Now: deprecated — use CSS border (and border-collapse for tables).
Images: omit the attribute; only 0 is allowed if it must appear.
Value: non-negative integer pixels — no units in the attribute.
One line: learn HTML border to read old pages — ship CSS border instead.
Frequently Asked Questions
On table, img, and object it set a border width in pixels. On tables it controlled the outer frame size. On images it drew a border around the picture.
Yes. MDN lists it as a legacy/deprecated attribute. Use the CSS border property instead for new pages.
It requests no border. The HTML living standard says authors should not put border on img; if it is present, its value must be the string 0. Prefer CSS (for example border: none).
The attribute mainly set the table’s outer frame. Inner cell lines were often affected by browser defaults or related attributes like rules. Today, style table, th, and td with CSS and usually border-collapse: collapse.
Historically table, img, and object. Do not invent border on arbitrary elements — use CSS on any element you need.
Many browsers still draw them for compatibility. That does not make them good practice for new HTML.