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

data-include

Applies to: any element

Fetches an external file and inserts its content as children of the element (or replaces the element entirely with data-include-replace).

Usage

<section data-include="sections/introduction.html"></section>
<section data-include="sections/api.md"
         data-include-format="markdown"></section>
<section data-include="sections/header.html"
         data-include-replace="true"></section>

Related attributes

Attribute Description
data-include-format Format of the included content: "html" (default) or "markdown"
data-include-replace If present, the element is replaced rather than having content inserted into it
data-oninclude Name of a function to call to transform the included content before insertion

Notes

  • Paths are relative to the including document
  • Includes are recursive up to a maximum depth of 3
  • Included content is processed by ReSpec just as if it were in the original document (WebIDL, definitions, links, etc. all work)
  • Must be served over HTTP/HTTPS — does not work with file:/// URLs. Use a local server during development.
  • Circular includes are not detected — avoid include loops

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