Skip to main content

HTML References

Deprecated Tags

Written by Updated Deprecated Tags exercises

Some HTML tags from the 1990s still work in browsers today, but they are no longer part of HTML. They were dropped because they mixed looks into the markup, and CSS now does that job far better.

What "deprecated" means here

Strictly, HTML5 calls these tags obsolete: you must not use them in new pages. Browsers still display most of them so that old websites do not break, and that is exactly what confuses beginners: "it works, so why not?" Because validators flag them, they cannot be styled from one stylesheet, and some carry no meaning for screen readers.

Here is a typical example, and its modern replacement:

html

<center>
  <h2>This is centered text</h2>
</center>

html

<h2 style="text-align: center;">This is centered text</h2>

The second version uses CSS for the centering. In a real site that CSS would sit in a stylesheet, not in a style attribute.

Obsolete tags and what to use instead

Old tagWhat it didUse today
<acronym>Marked an acronym<abbr>
<applet>Embedded a Java appletNothing; Java applets no longer run. Use JavaScript, or <object> for files.
<basefont>Set a default font for the pageCSS font-family and font-size on body
<big>Made text largerCSS font-size
<center>Centered contentCSS text-align: center or Flexbox
<dir>A directory list<ul>
<font>Set font face, size and colorCSS font-family, font-size, color
<frame>, <frameset>, <noframes>Split the window into frames<iframe>, or one page laid out with CSS Grid
<isindex>A one-field search box<form> with <input type="search">
<marquee>Scrolling textCSS animation, used carefully
<blink>Flashing textUsually nothing; flashing text is an accessibility problem
<strike>A line through text<s>, <del> or CSS text-decoration: line-through
<tt>Monospace text<code>, <kbd> or <samp>
<xmp>Preformatted text<pre>, with &lt; for any < signs

Two tags often wrongly listed as deprecated: <s> and <u>. Both are valid HTML5. They were given new meanings: <s> for text that is no longer accurate, <u> for a non-emphatic mark such as a spelling error.

Obsolete attributes

AttributeUsed onUse today
align<p>, <div>, <img>, <table>CSS text-align, Flexbox, or margin: 0 auto
bgcolor<body>, <table>, <td>CSS background-color
border<table>, <img>CSS border
width, height<table>, <td>CSS width and height
hspace, vspace<img>CSS margin
nowrap<td>CSS white-space: nowrap
valign<td>, <tr>CSS vertical-align

Note that width and height are still valid, and recommended, on <img>, <video> and <canvas>. They let the browser reserve space before the file loads.

Updating an old page

html

<body bgcolor="lightblue">
  <center>
    <font color="red" size="5">Welcome to My Page</font>
  </center>
</body>

html

<body style="background-color: lightblue;">
  <h1 style="text-align: center; color: red; font-size: 2em;">Welcome to My Page</h1>
</body>

The modern version puts every visual detail in CSS. The next step would be moving that CSS into a stylesheet, as shown in HTML Styles.

Check your own pages

The W3C Markup Validation Service lists every obsolete tag and attribute in a page. In VS Code, the HTMLHint extension warns you while you type.

Deprecated Tags exercises

Center without center

Write the paragraph Welcome and center its text with CSS.

Result

Check your answer to see it here.