Deprecated HTML Attributes
A list of deprecated HTML attributes, the tags they were used in, and the modern CSS property to use instead, with before/after migration examples.
A deprecated HTML attribute is one that the specification has marked as outdated and discourages you from using. Most of the attributes on this page were presentational — they controlled how content looked (color, size, alignment, spacing). When HTML5 replaced HTML 4.01, the spec deliberately moved this styling responsibility out of HTML and into CSS, so that markup describes structure and stylesheets describe appearance.
Why these attributes were dropped
In the HTML4 era it was common to write <td bgcolor="#ff0000"> or <font size="5"> directly in your markup. HTML5 removed these because mixing presentation into HTML has real costs:
- Separation of concerns. Styling lives in CSS, so one rule can restyle every cell instead of repeating an attribute on each tag.
- Maintainability. Changing a site-wide color means editing one stylesheet, not hunting through hundreds of inline attributes.
- Validation. The W3C Markup Validator and HTML linters report deprecated and obsolete attributes as errors or warnings, so they fail modern build/CI checks.
- Future-proofing. Browsers still render most of these through legacy parsing rules, so a page using them usually looks fine today. The risk is not immediate breakage — it is that the attribute is no longer part of the spec and support can be dropped in the future.
In short: deprecated attributes typically still work, but you should migrate them to CSS. The "Alternate" column below tells you which property to use.
Deprecated is not the same as obsolete (removed). A deprecated attribute is discouraged but generally still parsed by browsers. An obsolete feature has been removed from the spec entirely — for example, basefont here refers to the fully obsolete <basefont> element, which modern browsers may ignore. Treat anything on this page as something to replace, and obsolete features as something that may already do nothing.
Before and after: replacing a deprecated attribute with CSS
The migration pattern is always the same — delete the presentational attribute and move the intent into a CSS rule. For example, a red table cell:
<!-- Deprecated: presentation baked into the markup -->
<td bgcolor="#ff0000">Sale</td>
<!-- Modern: structure in HTML, color in CSS -->
<td class="sale">Sale</td>.sale {
background-color: #ff0000;
}A few more common conversions side by side:
<!-- align on a paragraph -->
<p align="center">Hello</p> → <p class="centered">Hello</p>
<!-- width/height on an image's wrapper, spacing around an image -->
<img src="logo.png" hspace="10" vspace="10"> → <img src="logo.png" class="spaced">
<!-- text color on the page body -->
<body text="#333333"> → <body> (styled in CSS).centered { text-align: center; }
.spaced { margin: 10px; }
body { color: #333333; }List of deprecated HTML attributes
The attributes below are deprecated in the listed tags and should be replaced by the property shown in the Alternate column.
| Attributes | Description | Deprecated in | Alternate |
|---|---|---|---|
| align | Specifies the alignment of the element | <caption>, <img>, <table>, <hr>, <div>, <h1>-<h6>, <p> | CSS text-align, float and vertical-align properties |
| alink | Specifies the color of an active link in a document | <body> | CSS active Pseudo Class |
| background | Specifies the background image | <body> | CSS background-image Property |
| bgcolor | Specifies the background color | <body>, <table>, <tr>, <td>, <th> | CSS background-color Property |
| border | Specifies the width of the border | <img>, <object> | CSS border-width Property |
| clear | Clears any right or left alignments | <br> | CSS clear Property |
| compact | Specifies that the list should render smaller than normal | <ol>, <ul> | CSS font-size, margin and line-height for a tighter list |
| height | Specifies the height of the element | <table> | CSS height Property |
| hspace | Specifies the whitespace or padding on left or right sides of an element | <img>, <object> | CSS padding Property |
| language | Specifies scripting language | <script> | The type attribute |
| link | Specifies the default color of the links | <body> | CSS link Pseudo Class |
| noshade | It specifies that a horizontal line should render in one solid color (noshaded) | <hr> | CSS border-style Property |
| nowrap | Specifies that the text should not wrap within the table cell | <td>, <th> | CSS white-space Property |
| size | Specifies the initial width for the input field and a number of visible rows for the select element | <basefont>, <font>, <hr> | CSS width Property |
| text | Specifies the color of the text | <body> | CSS color property |
| type | Specifies the type of list | <li> | CSS list-style-type Property |
| vlink | Specifies the color of visited links | <body> | CSS visited Pseudo Class |
| valign | Specifies vertical alignment of cell content | <td>, <th>, <tr> | CSS vertical-align Property |
| vspace | Specifies the whitespace or padding above or below an element | <img>,<object> | CSS padding Property |
| width | Specifies the width of the element | <hr>,<pre>,<td>,<th> | CSS width Property |
Not everything that looks "old" is deprecated. The start attribute on <ol> (which sets the first number) and the value attribute on <li> (which sets a specific item's number) are still valid in HTML5 — they affect the list's semantics, not just its appearance, so there is no need to replace them with CSS.
Where to next
- See the full HTML Attributes overview to learn how attributes work and which ones are current.
- New to moving styles into stylesheets? Start with CSS Syntax and the CSS Introduction.