liveBook · Manning

Data attribute

As explained in Tiny CSS Projects

A data attribute is a custom HTML attribute whose name begins with data- and whose value stores application-specific information.

A data attribute is a custom HTML attribute beginning with data- that stores application-specific information. In a responsive checkout table, data-name stores each cell’s label for mobile presentation. section 8.3.1

Labeling a mobile checkout table

Add <td data-name="Item">Red Grapes, 1lb</td>, then use td[data-name]::before with content: attr(data-name) ":"; to display “Item:” before the cell content. Keep the table header visually hidden rather than using display:none so assistive technologies can still access it. section 8.3.1

How Tiny CSS Projects covers it

How deep it goes
Shows attribute syntax, CSS selection, attr(), alignment, and accessibility handling, but does not discuss JavaScript data-attribute APIs.
Examples
Demonstrates data-name on checkout-table cells and displays labels such as Item: before their contents.
What it assumes
Assumes basic HTML tables, CSS media queries, pseudo-elements, and responsive layout techniques.
What you can do after
Apply it via CSS selectors, pseudo-elements, and attr() to create labeled mobile table cells.
How it connects
Connects data attributes with responsive web design, CSS pseudo-elements, the attr() function, HTML tables, and accessibility.

Also explained in

Compare how 2 books explain data attribute →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Tiny CSS Projects. The section links point to the parts of the book it draws on.