Difference between HTML4 and HTML5?

HTML5 replaced HTML 4.01 with a simpler doctype, semantic elements (header, nav, main, article, section, footer), native audio and video, canvas and SVG inline, new form input types and validation, and APIs like local storage, geolocation and history. It also defined precise parsing rules so all browsers handle errors the same way. Today "HTML5" is simply HTML, a Living Standard maintained by the WHATWG.

Main differences

HTML 4.01HTML5 / HTML Living Standard
Doctypelong, DTD-based<!doctype html>
Charset<meta http-equiv="Content-Type" ...><meta charset="utf-8">
Layout markup<div id="header"> everywheresemantic elements
Mediaplugins (Flash, Silverlight)<video>, <audio>, <track>
Graphicsimages and plugins<canvas>, inline <svg>
Formstext, password, checkbox, radioemail, url, date, number, range, color, search; required, pattern, placeholder
Parsingbrowser-specific error handlingstandardized parsing algorithm
Presentational tags<font>, <center>, <frame>removed; use CSS
APIsfewWeb Storage, History, Drag and Drop, Web Workers, and many more

Living Standard

After HTML5 (2014), the W3C and WHATWG agreed in 2019 that the WHATWG HTML Living Standard is the single source of truth. Features are added continuously: <dialog>, popover, <search>, inert, exclusive <details name>, loading="lazy", fetchpriority, invoker commands (command/commandfor).

Interview tip

Mention semantics, multimedia, forms and APIs, then note that version numbers no longer exist.

Code example

html
1<!-- HTML 4.01 style -->
2<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
3<div id="header"><font size="5">Site</font></div>
4<object data="movie.swf" type="application/x-shockwave-flash"></object> -->
5
6<!-- Modern HTML -->
7<header><h1>Site</h1></header>
8<main>
9 <video controls width="320" preload="metadata" poster="https://picsum.photos/320/180">
10 <source src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm" type="video/webm">
11 Your browser does not support video.
12 </video>
13 <form>
14 <label>Email <input type="email" required placeholder="you@example.com"></label>
15 <label>Date <input type="date"></label>
16 <label>Volume <input type="range" min="0" max="10"></label>
17 <button>Send</button>
18 </form>
19 <canvas id="c" width="120" height="40" style="border:1px solid #ccc"></canvas>
20</main>
21<script>document.getElementById("c").getContext("2d").fillRect(10, 10, 60, 20);</script>

Practice this question

Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the HTML & CSS set.

Open in study app