Ace the Angular Interview 2025 – Code Your Way to Success!

Question: 1 / 400

What should be used to create a custom attribute in HTML?

data-custom

The correct approach for creating a custom attribute in HTML is to use the 'data-' prefix, which is part of the HTML5 specification. By using 'data-custom', developers can define custom attributes that can store additional information on standard HTML elements without needing to use non-standard attributes. This approach ensures that the attributes are valid, maintained, and appropriately recognized by the browser.

Using custom attributes starting with 'data-' allows you to embed custom data attributes in your HTML elements. This attribute can be accessed via JavaScript, enabling dynamic manipulation and interaction with the stored data.

The other options do not conform to the HTML5 custom data attribute standards. For instance, 'custom-data', 'attr-custom', and 'set-custom' do not use the 'data-' prefix, which makes them invalid according to the specification for custom attributes. Only attributes prefixed with 'data-' will be treated as valid and recognized as custom attributes by the HTML parser and various web APIs.

Get further explanation with Examzify DeepDiveBeta

custom-data

attr-custom

set-custom

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy