HTML5 New Features
Input Types, Local Storage, ContentEditable, Data Attributes

HTML5 New Features: A Smarter, More Powerful Web

HTML5 isn’t just an upgrade — it’s a reimagination. It introduced modern elements, smarter forms, richer interactivity, and built-in features developers used to rely on JavaScript or plugins for. Let’s explore some of the most exciting and practical additions.

1. New Input Types for Forms

HTML5 introduced several new <input> types that make form validation and interaction smoother and more semantic.

Examples of New Input Types:

<form>
  Date: <input type="date"><br>
  Email: <input type="email"><br>
  Number: <input type="number" min="1" max="10"><br>
  Range: <input type="range" min="0" max="100"><br>
  Color: <input type="color"><br>
  Search: <input type="search">
</form>
[ Browser renders appropriate controls: calendar, slider, etc. ]

These input types improve user experience and reduce the need for custom scripts.

2. Local Storage

With HTML5, you can store data on the user's browser — no server required. This is useful for saving preferences, carts, or game scores.

Storing and Retrieving Data

<button onclick="saveCherry()">Save Cherry</button>
<button onclick="loadCherry()">Load Cherry</button>
<p id="output"></p>

<script>
function saveCherry() {
  localStorage.setItem('fruit', 'Cherry');
}

function loadCherry() {
  const fruit = localStorage.getItem('fruit');
  document.getElementById('output').innerText = fruit ? 'Saved: ' + fruit : 'Nothing saved yet.';
}
</script>
[ Click "Save Cherry" → then "Load Cherry" → Text updates with saved value ]

3. ContentEditable

Make any HTML element editable — without a form or JavaScript. Perfect for note-taking, CMS interfaces, or quick content testing.

<p contenteditable="true">You can edit this banana fact right in the browser.</p>
[ You can click and type directly inside the paragraph ]

4. Data Attributes (data-*)

Custom attributes starting with data- let you store extra information right in your HTML elements — ideal for dynamic content, tooltips, or JavaScript hooks.

<div id="fruitBox" data-fruit="apple" onclick="showFruit()">
  Click me to see what's inside!
</div>

<script>
function showFruit() {
  const box = document.getElementById("fruitBox");
  alert("The fruit is: " + box.dataset.fruit);
}
</script>
[ Clicking the box shows “The fruit is: apple” ]

5. HTML5 vs HTML4 — What Changed?

| Feature | HTML4 | HTML5 | |--------|-------|-------| | Input Types | Limited (text, checkbox, radio) | Dozens (email, date, range, color…) | | Multimedia | Requires plugins | Built-in <audio> and <video> | | Storage | Cookies only | LocalStorage and SessionStorage | | Custom Data | Not supported | data-* attributes | | Semantic Tags | Mostly <div> and <span> | New tags like <section>, <article>, <nav>, <main> | | Doctype | Long and clunky | <!DOCTYPE html> (simplified) |

Summary

HTML5 made the web smarter, leaner, and more user-friendly. Here’s what you’ve unlocked today:

  • Use of new <input> types for better UX
  • Storing data with localStorage
  • Editable content using contenteditable
  • Dynamic attributes with data-*
  • A clearer understanding of HTML5 vs HTML4

What’s Next?

Coming up: We’ll explore how HTML5 works hand-in-hand with modern CSS and JavaScript to create rich, app-like user experiences — all in the browser.

QUIZ

Question 1:Which of the following is NOT a new input type introduced in HTML5?

Question 2:Local Storage allows storing data that persists even after the browser is closed.

Question 3:Which of the following are valid uses of the contenteditable attribute in HTML5?

Question 4:How are custom data attributes defined in HTML5?

Question 5:HTML5 deprecated the font tag and encourages using CSS for styling instead.

Question 6:What are some advantages of HTML5 over HTML4?