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 2 Manning books explain it

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 →

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 →

Related concepts

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.