Examples
Default
Basic article with header and content.
<article> <header> <h2>Article Title</h2> <p>Published on <time datetime="2024-01-15">January 15, 2024</time></p> </header> <p>This is the main content of the article.</p> <footer> <p>Written by Jane Doe</p> </footer></article>
.blog
Optimized for long-form reading. The article is centred and capped at --prose-measure (default 65ch), the header gets extra space below it, and the footer is separated by a top border. It also gets the prose typography described under Prose typography.
<article class="blog"> <header> <h2>How to Write Better Articles</h2> <p><time datetime="2024-01-15">January 15, 2024</time> in Writing</p> </header> <p>Writing compelling articles requires understanding your audience, structuring your thoughts clearly, and revising thoroughly.</p> <footer> <p>By Jane Doe | 5 min read</p> </footer></article>
.card
Card-style article with border, background, and padding.
<article class="card"> <h3>Product Feature Update</h3> <p>We have released new features that improve performance by 40% and add dark mode support.</p> <a href="#">Read more</a></article>
.feature
Hero-style feature article with centered header.
<article class="feature"> <header> <h2>Introducing Vanilla Breeze</h2> <p>A layered HTML component system for modern web development</p> </header> <p>Build accessible, performant websites with native HTML elements enhanced through progressive CSS styling.</p></article>
.compact
Compact list-item style for article listings: a horizontal flex row with a bottom border (dropped on the last article). A leading image, picture, SVG or video keeps its size and gets a small radius; the other child (typically a <section> or <header>) fills the remaining width.
<article class="compact"> <img src="thumb.jpg" alt="Thumbnail" /> <section> <h3>Getting Started with CSS Grid</h3> <p>Learn the fundamentals of CSS Grid layout.</p> </section></article>
.nested
Nested articles for comments and replies with indentation.
<article> <header> <strong>User123</strong> <time datetime="2024-01-15T10:30">10:30 AM</time> </header> <p>This is a great article! Thanks for sharing.</p> <article class="nested"> <header> <strong>Author</strong> <time datetime="2024-01-15T11:00">11:00 AM</time> </header> <p>Thank you for the kind words!</p> </article></article>
data-numbered
Academic-style auto-numbering. CSS counters prefix h2–h4 headings with hierarchical numbers (1., 1.1., 1.1.1.) and prepend "Figure N:", "Table N:" and "Listing N:" labels to captions. The numbering runs through the whole article, across <section> elements. For numbered lists use <ol>; for legal-style § numbering use data-section-numbers.
<article data-numbered> <section> <h2>Origins of Movable Type</h2> <p>Movable type was first developed in China...</p> <h3>Gutenberg's Press</h3> <p>Johannes Gutenberg independently invented...</p> <aside> <h3>A note on dates</h3> <p>Headings in an aside are not part of the outline, so this one is not numbered.</p> </aside> <h3>Spread Across Europe</h3> </section> <section> <h2>The Typographic Tradition</h2> <figure> <img src="press.jpg" alt="Historical printing press" /> <figcaption>A reconstructed printing press.</figcaption> </figure> <figure> <figure> <img src="blackletter.jpg" alt="A page set in blackletter type" /> <figcaption>Blackletter</figcaption> </figure> <figure> <img src="roman.jpg" alt="A page set in roman type" /> <figcaption>Roman</figcaption> </figure> <figcaption>Two early type styles.</figcaption> </figure> <table> <caption>Key milestones in the history of printing</caption> ... </table> </section></article>
What gets numbered
- Headings:
h2, h3 and h4 anywhere in the article, sections included. Headings inside a nested <aside> or <article> (a sidebar note, a comment) are left unnumbered.
- Figures: a
<figure> with a <figcaption>. Quote figures (figure.quote) are skipped, and a figure without a caption does not use up a number.
- Tables: a
<table> with a <caption>. Uncaptioned tables are not counted.
- Listings: a captioned
figure.code is counted separately as "Listing N".
- Subfigures: a
<figure> nested directly in another figure sits inline beside its siblings, and its caption is lettered (a), (b) and so on.
Number from h2 down. An h3 that comes before the first h2 renders as "0.1." because there is no h2 number yet.
Articles, sections and asides are normally container-query containers. A container's style containment would restart the counters in every section, so a numbered article and the sections and asides inside it are not containers; container queries inside resolve against the next container out, usually <main>. Adding data-container to one of them turns it back into a container, and numbering inside it then starts again from 1.
Styling and translation
| Custom property | Default | Effect |
--label-figure | "Figure" | Prefix for figure captions |
--label-table | "Table" | Prefix for table captions |
--label-listing | "Listing" | Prefix for figure.code captions |
--numbered-style | decimal | Counter style for the heading numbers, for example arabic-indic, devanagari, cjk-decimal or your own @counter-style name |
Set them on article[data-numbered], typically per language:
article[data-numbered]:lang(de) { --label-figure: "Abbildung"; --label-table: "Tabelle";} article[data-numbered]:lang(ar) { --label-figure: "شكل"; --numbered-style: arabic-indic;}
The numbers are generated content in --color-text-muted. Screen readers read generated content, so the numbers are announced with the heading, which helps when a document cross-references "section 2.1".
data-section-numbers
Section-sign numbering for legal and policy documents, separate from the outline numbering of data-numbered. Each h2 is prefixed § 1, § 2, and each h3 beneath it § 1a, § 1b, in the interactive colour. Like data-numbered, the count runs across sections and skips headings in a nested <aside> or <article>. Set --sep-section to replace the § sign.
<article data-section-numbers> <section> <h2>Definitions</h2> <h3>Account</h3> <h3>Content</h3> </section> <section> <h2>Use of the Service</h2> <h3>Restrictions</h3> </section></article>
data-drop-cap
Adds a large decorative initial letter to the opening paragraph, a convention borrowed from illuminated manuscripts and editorial print design. The drop cap goes on the article's first direct <p>; if the article has no direct paragraph, it goes on the first paragraph of the first direct <section>. data-drop-cap also works on a single <p>.
Browsers that support initial-letter sink the letter into the first lines of text; others get a floated letter of about the same size. Both are logical, so in right-to-left text the cap sits on the right. Themes never add a drop cap on their own: only elements with data-drop-cap get one, and themes such as editorial and Swiss only change its colour, font and weight.
<article data-drop-cap> <p>When the first rays of morning light crept through the cathedral windows, they illuminated row upon row of hand-set lead type...</p></article>
Styling hooks
| Custom property | Default | Effect |
--drop-cap-lines | 3 | Number of lines the letter spans |
--drop-cap-color | var(--color-primary) | Letter colour |
--drop-cap-font | inherit | Letter font family |
--drop-cap-weight | 700 | Letter font weight |
.essay[data-drop-cap] { --drop-cap-lines: 2; --drop-cap-font: var(--font-heading);}
The browser decides what ::first-letter covers: an opening quotation mark or other punctuation is enlarged together with the letter after it. Drop caps are designed for horizontal text; in a vertical writing-mode, test before using one. Screen readers read the paragraph normally, because the cap is a style on the real first letter.
data-prose
Long-form typography for markdown or CMS content you do not control: the reading line height, old-style numerals and hyphenation listed under Prose typography, plus floated images. Every image (or <picture>) that is a direct child of a paragraph floats to the inline-end, capped at half the content width, so text that shares the paragraph wraps around it. Headings (h2–h4), <hr> and the footer clear the float, so an image never spills into the next section.
CSS cannot see text, so a paragraph that holds only an image floats too. Wrap an image that should span the column in a <figure>.
<article data-prose> <p> <img src="meadow.jpg" alt="Wildflowers" /> The alpine meadows above the treeline host an extraordinary diversity of wildflowers during the brief summer season... </p></article>
data-prose, .blog or data-layout="prose"?
article[data-prose] styles the text: prose typography and image floats. It sets no width.
article.blog is the same typography plus a centred column capped at --prose-measure (65ch) with spaced header and footer. It does not float images. Combine both (class="blog" data-prose) for a centred column with floats.
data-layout="prose" / <layout-text> is layout: reading measure and vertical rhythm between blocks, on any element. It pairs with data-prose on the same article.
Prose typography (.blog and data-prose)
Both .blog and data-prose apply the same reading typography:
- Line height of
--prose-line-height (default 1.6)
- Old-style, proportional numerals (
font-variant-numeric: oldstyle-nums proportional-nums)
- Body text stepped up to
--font-size-l when the surrounding column (the nearest main, section, aside or other container) is at least 40rem wide, so the same article keeps body-size text in a narrow sidebar column
- Automatic hyphenation with conservative limits. It needs a
lang attribute on the article or any ancestor, usually <html>
data-highlights
Enables Medium-style text highlighting and private notes. data-highlights turns on the engine, which stores, restores and paints highlights. It renders no UI of its own: the selection toolbar comes from a <selection-menu> pointed at the article, holding a <highlight-wc> (colour palette) and a <note-wc> (notes). Select text, pick a colour, and the highlight is saved to localStorage. Highlights with notes get a margin annotation; click it to open or edit the note.
<article id="essay" data-highlights> <p>Select any text in this article to highlight it. Choose a color from the toolbar that appears above your selection.</p></article> <selection-menu for="essay"> <highlight-wc></highlight-wc> <note-wc></note-wc></selection-menu>
data-highlights (custom colors)
List the palette in data-highlights-colors (which colours the engine paints) and in the colors attribute of <highlight-wc> (which swatches the toolbar offers), then define a --highlight-{name} custom property for each name in your stylesheet. Names may contain letters, digits, hyphens and underscores. Each article paints its own palette, so several articles with different palettes can share a page, and a --highlight-{name} set on one article applies only to it.
<article id="review" class="custom-colors" data-highlights data-highlights-colors="red,orange,teal"> <p>Custom highlight palette.</p></article> <selection-menu for="review"> <highlight-wc colors="red,orange,teal"></highlight-wc> <note-wc></note-wc></selection-menu>
.custom-colors { --highlight-red: oklch(89% 0.06 18); --highlight-orange: oklch(91% 0.07 62); --highlight-teal: oklch(91% 0.08 180);}
data-highlights (readonly)
Add data-highlights-readonly to render stored highlights without allowing new ones. No <selection-menu> is needed.
<article data-highlights data-highlights-readonly> <p>Renders stored highlights without allowing new ones.</p></article>