liveBook · Manning

Data attribute

An HTML data attribute is a custom attribute whose name begins with data- and whose value stores application-specific information on an element.

How 4 Manning books explain it

HTML5 in Action

An HTML data-* attribute associates custom application-specific data with an element.

How it is used
Uses data attributes to bind application data to elements for JavaScript-driven form calculations and editor controls.
How deep it goes
Explains markup, dataset naming, retrieval, calculations, and a legacy-browser fallback without attempting comprehensive coverage.
Examples
Uses product prices on quantity inputs and command data on editor formatting buttons.
What you can do after
Apply data attributes using dataset or getAttribute to retrieve element-associated values for calculations.

Read how HTML5 in Action explains data attribute →

BDD in Action, Second Edition

An HTML data attribute is a custom data-* attribute for storing additional information on a standard HTML element.

How it is used
Supports automated UI tests by providing element locators that are less coupled to page layout and implementation details.
How deep it goes
Defines the purpose, compares locator stability, and demonstrates HTML usage, but does not develop data-attribute internals.
Examples
Uses a login form with data-testid values for email, password, and login controls.
What you can do after
Apply it via WebDriver by adding data-testid markers to HTML controls and using them as test locators.

Read how BDD in Action, Second Edition explains data attribute →

Vanilla Web

A custom HTML attribute whose name begins with data- and whose value stores application-specific information on an element.

How it is used
Stores small element metadata and marks DOM locations for explicit data binding or CSS-driven presentation.
How deep it goes
Defines dataset mapping and works through a binding function, while distinguishing its explicit rendering pass from automatic reactivity.
Examples
Uses product-field binding markers, a disabled button, and a data-status attribute for CSS-selected state.
What you can do after
Build it from scratch: implement a small dataset-driven binding pass and rerun it when state changes.

Read how Vanilla Web explains data attribute →

Tiny CSS Projects

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

How it is used
Uses custom attributes to label mobile table cells after responsive CSS transforms rows into card-like layouts.
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 you can do after
Apply it via CSS selectors, pseudo-elements, and attr() to create labeled mobile table cells.

Read how Tiny CSS Projects explains data attribute →

Also covered in

What to know first

Related concepts

Questions about data attribute

What is data attribute?

An HTML data attribute is a custom attribute whose name begins with data- and whose value stores application-specific information on an element.

Which Manning books explain data attribute?

HTML5 in Action, BDD in Action, Second Edition, Vanilla Web and Tiny CSS Projects.

What should I know before learning data attribute?

Manning books that teach data attribute usually introduce CSS, HTML5 and JavaScript first.

What is the difference between data attribute and attribute?

An HTML data attribute is a custom attribute whose name begins with data- and whose value stores application-specific information on an element. An attribute is a named property or piece of information associated with an entity, object, or structured data item.

What is data attribute part of?

Data attribute is part of HTML. HTML is the standard markup language for structuring content and elements in documents on the web.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.