Custom Data Attributes

๐ŸŒ HTML5 ๐ŸŸข Chapter 29 of 37 ๐Ÿ“‚ Phase 11: HTML APIs & Features ๐Ÿ“… 2026 Edition
๐Ÿ“Œ Covered in this chapter: data-* Attributes Standard ยท Why Data Attributes are Used ยท Reading via element.dataset ยท Storing IDs & UI State ยท CSS Attribute Selectors ยท Data Attributes vs Classes
Welcome to Phase 11 (Chapter 29): Custom Data Attributes! Per WHATWG standards, data-* attributes store application-specific custom data or UI state directly on HTML elements.
1Data Attribute Syntax
HTML + JS โ€” dataset Property โ–ถ Run in HTML Editor
<button data-course-id="python" data-status="active" onclick="alert(this.dataset.courseId)">
  Open Course
</button>
OC
Written by Our Compiler Technical Editorial Team
Reviewed for accuracy & tested on HTML5 Standards ยท Last updated August 2026