W3docs

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.

Warning

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.

AttributesDescriptionDeprecated inAlternate
alignSpecifies the alignment of the element<caption>, <img>, <table>, <hr>, <div>, <h1>-<h6>, <p>CSS text-align, float and vertical-align properties
alinkSpecifies the color of an active link in a document<body>CSS active Pseudo Class
backgroundSpecifies the background image<body>CSS background-image Property
bgcolorSpecifies the background color<body>, <table>, <tr>, <td>, <th>CSS background-color Property
borderSpecifies the width of the border<img>, <object>CSS border-width Property
clearClears any right or left alignments<br>CSS clear Property
compactSpecifies that the list should render smaller than normal<ol>, <ul>CSS font-size, margin and line-height for a tighter list
heightSpecifies the height of the element<table>CSS height Property
hspaceSpecifies the whitespace or padding on left or right sides of an element<img>, <object>CSS padding Property
languageSpecifies scripting language<script>The type attribute
linkSpecifies the default color of the links<body>CSS link Pseudo Class
noshadeIt specifies that a horizontal line should render in one solid color (noshaded)<hr>CSS border-style Property
nowrapSpecifies that the text should not wrap within the table cell<td>, <th>CSS white-space Property
sizeSpecifies the initial width for the input field and a number of visible rows for the select element<basefont>, <font>, <hr>CSS width Property
textSpecifies the color of the text<body>CSS color property
typeSpecifies the type of list<li>CSS list-style-type Property
vlinkSpecifies the color of visited links<body>CSS visited Pseudo Class
valignSpecifies vertical alignment of cell content<td>, <th>, <tr>CSS vertical-align Property
vspaceSpecifies the whitespace or padding above or below an element<img>,<object>CSS padding Property
widthSpecifies the width of the element<hr>,<pre>,<td>,<th>CSS width Property
Info

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

Practice

Practice
A page uses align='center' on a paragraph. Which is the correct modern replacement?
A page uses align='center' on a paragraph. Which is the correct modern replacement?
Practice
Why should you migrate deprecated presentational attributes to CSS even though browsers still render them?
Why should you migrate deprecated presentational attributes to CSS even though browsers still render them?
Practice
Which of the following are deprecated HTML attributes according to W3docs?
Which of the following are deprecated HTML attributes according to W3docs?
Was this page helpful?