Using Data Attributes in HTML
📖 Scenario: You are creating a simple product list for an online store. Each product needs to store extra information like its ID and category without showing it directly on the page.
🎯 Goal: Build an HTML page with a list of products. Each product item should use data- attributes to store its id and category. This helps keep extra info in the HTML that can be used later by scripts or styles.
📋 What You'll Learn
Create an unordered list with three product items.
Each product item must have
data-id and data-category attributes with exact values.Use semantic HTML5 elements.
Ensure the HTML is valid and accessible.
💡 Why This Matters
🌍 Real World
Data attributes are used in real websites to store extra info on elements that JavaScript or CSS can use without cluttering the visible content.
💼 Career
Knowing how to use data attributes helps you build interactive and maintainable web pages, a common skill needed for front-end web development jobs.
Progress0 / 4 steps