Trivia Questions1 min readPremium

Can you explain tag attributes such as disabled, async, defer, and when to use data-*? Each of these HTML attributes is documented in MDN’s attribute reference.

Deciphering HTML Tag Attributes: disabled, async, defer, and data-*

HTML tag attributes like disabled, async, defer, and data-* provide powerful mechanisms for enhancing functionality and tailoring the behavior of web page elements.

The disabled Attribute

The disabled attribute is pivotal for controlling user interaction with form elements such as buttons and input fields. When set, it renders the element unclickable and uneditable, effectively sidelining it from user interaction. This attribute proves invaluable in scenarios requiring user completion of certain prerequisites—like form field validation—prior to engagement with the element.

The async Attribute

Utilizing the async attribute on a script tag allows the browser to keep parsing the page while asynchronously downloading the script, then runs the script as soon as it finishes downloading (briefly pausing parsing at that point). This non-blocking behavior is ideal for scripts that do not impact immediate page rendering or functionality, such as analytics or third-party widgets. It’s crucial, however, to be mindful of script dependencies due to the asynchronous nature of async, which does not guarantee script execution order.

The... premium content.

Premium

Keep reading with Premium

Get the rest of this guide plus every premium question, solution, and system design deep dive.

  • All premium solutions
  • System design deep dives
  • Company-specific prep

4.9/5 from our users