Laptop
\nA powerful laptop for work and play.
\n{
"$schema": "../schemas/code-crispies-module-schema.json",
"id": "html-data-attributes",
"title": "Custom Data Attributes",
"description": "Store custom data on HTML elements with data-* attributes",
"mode": "html",
"difficulty": "beginner",
"lessons": [
{
"id": "data-attributes-intro",
"title": "Adding Data Attributes",
"description": "Custom data-* attributes let you store extra information on any HTML element. The attribute name starts with data- followed by your custom name. A powerful laptop for work and play. A comfortable cotton t-shirt.
Examples: data-id, data-category, data-price",
"task": "Create two product cards using <article> elements. Each should have:
1. A data-category attribute (e.g., 'electronics' or 'clothing')
2. A data-price attribute with a number
3. An <h2> with the product name",
"previewHTML": "",
"previewBaseCSS": "body { font-family: system-ui; padding: 20px; display: grid; gap: 15px; } article { padding: 20px; border-radius: 10px; background: #f5f5f5; border-left: 4px solid #ccc; } article[data-category='electronics'] { border-left-color: #2196f3; background: #e3f2fd; } article[data-category='clothing'] { border-left-color: #e91e63; background: #fce4ec; } h2 { margin: 0 0 10px 0; } article::after { content: '€' attr(data-price); display: block; font-weight: bold; color: #4caf50; margin-top: 10px; }",
"sandboxCSS": "",
"initialCode": "",
"solution": "Laptop
\n T-Shirt
\n