Prepare for Angular Interviews with real-life questions. Utilize quizzes and examples to deepen understanding and enhance your skills. Gear up to ace your interview!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


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

  1. data-custom

  2. custom-data

  3. attr-custom

  4. set-custom

The correct answer is: 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.