Skip to content
Marcos Caceres edited this page Mar 27, 2026 · 11 revisions

data-dfn-for

Applies to: <dfn>, <section>, <a>

Sets the context (scope) for a definition or link — typically the name of the IDL interface, dictionary, or element that a member belongs to. Also used on <section> to set the default context for all definitions and links within.

Usage

<section data-dfn-for="Request" data-link-for="Request">
  <h2><code>Request</code> interface</h2>
  <pre class="idl">
  interface Request {
    readonly attribute USVString method;
    Promise&lt;Response&gt; clone();
  };
  </pre>
  <p>The <dfn>Request</dfn> interface represents a resource request.</p>
  <p>The <dfn>method</dfn> attribute returns the request method.</p>
  <p>The <dfn>clone()</dfn> method returns a copy of the request.</p>
</section>
<dfn data-dfn-for="Request">method</dfn>
<dfn data-dfn-for="Response">type</dfn>

Notes

  • Set data-dfn-for on a <section> to apply the context to all <dfn> elements within that section (avoids repeating it on every dfn)
  • Use data-link-for to set the default context for links within a section
  • Required when two different interfaces have members with the same name — disambiguates which one you're defining
  • WebIDL members inside <pre class="idl"> automatically get data-dfn-for set from their parent interface; you only need this for the prose dfns

Guides

Configuration options

W3C Configuration options

Linting rules

Internal properties

Handled by ReSpec for you.

Special <section> IDs

HTML elements

Custom Elements

HTML attributes

CSS Classes

Special properties

Clone this wiki locally