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.
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.
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.
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.
Also covered in
What to know first
- CSSCSS (Cascading Style Sheets) is a stylesheet language for specifying the presentation and layout of structured documents.
- HTML5HTML5 is a version of the HTML standard that defines markup and APIs for structuring and presenting web content.
- JavaScriptJavaScript is a high-level, dynamically typed programming language standardized as ECMAScript and used for web and general-purpose programming.
Related concepts
- datasetuses · The dataset property of an HTML element exposes its data-* attributes as a collection of string values keyed by the attribute names with the data- prefix removed and hyphenated names converted to camel case.
- data bindingimplements · Data binding is a technique that connects application data with a user interface so values or changes can be represented or synchronized between them.
- HTMLpart of · HTML is the standard markup language for structuring content and elements in documents on the web.
- razor expressionused by · A Razor expression is an inline construct that evaluates an embedded C# expression and inserts its result into generated output.
- Document Object Modelused by · The Document Object Model is a platform-independent programming interface that represents a document as a structured tree of nodes and provides ways to access and modify its content and structure.
- attributecontrasts with · An attribute is a named property or piece of information associated with an entity, object, or structured data item.
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.



