article

Self-contained, independently distributable content such as blog posts, news articles, forum posts, product cards, or user comments.

Usage

Use the <article> element for content that:

  • Makes sense on its own, outside the context of the page
  • Could be syndicated or shared independently (RSS, social media)
  • Represents a complete, self-contained composition

Common uses include blog posts, news articles, product cards, forum posts, comments, and widgets.

Examples

Default

Basic article with header and content.

.blog

Optimized for long-form reading with constrained width (65ch).

.card

Card-style article with border, background, and padding.

.feature

Hero-style feature article with centered header.

.compact

Compact list-item style for article listings.

.nested

Nested articles for comments and replies with indentation.

data-numbered

Academic-style auto-numbering for headings, figures, and tables. CSS counters automatically prefix h2-h4 headings with hierarchical numbers, and prepend "Figure" / "Table" labels to captions.

data-drop-cap

Adds a large decorative initial letter to the opening paragraph, a convention borrowed from illuminated manuscripts and editorial print design.

data-prose

Automatically floats images that appear inside paragraphs to the inline-end, sized to half the content width. Ideal for markdown or CMS-generated content where images are placed directly within paragraph text.

data-highlights

Enables Medium-style text highlighting and private notes. Select text to see a floating toolbar with color swatches. Click an existing highlight to change color, add a note, or remove it. Highlights persist in localStorage.

data-highlights (custom colors)

Use data-highlights-colors to provide a custom palette and define matching --highlight-{name} custom properties.

data-highlights (readonly)

Add data-highlights-readonly to render stored highlights without allowing new ones.

Variants

Class Description
.blog Long-form reading layout with 65ch max-width, spaced header/footer
.card Card styling with border, background, padding, and rounded corners
.feature Grid layout with centered header for hero-style content
.compact Flexbox horizontal layout for article listings
.nested Indented with left border for threaded comments/replies
data-numbered Academic-style auto-numbering for h2-h4 headings, figures, tables, and code listings
data-drop-cap Large decorative first letter on the opening paragraph
data-prose Auto-float images inside paragraphs for markdown/CMS content
data-highlights Text highlighting and private notes with localStorage persistence

Accessibility

  • Articles create landmark regions that screen readers can navigate to
  • Always include a heading (h1-h6) to label the article content
  • Use <header> and <footer> within articles for structured metadata
  • Include <time> elements with datetime attributes for publication dates
  • Nested articles maintain proper heading hierarchy (avoid skipping levels)

Highlights API

The data-highlights attribute activates a JavaScript controller that provides a programmatic API for managing highlights.

Attributes

Attribute Description
data-highlights Enables highlighting. Optional string value becomes the localStorage key suffix (default: page pathname).
data-highlights-colors Comma-separated color names. Each maps to a --highlight-{name} CSS custom property. Default: yellow,green,blue,pink
data-highlights-readonly Renders stored highlights but disables creating new ones.

Events

Event Detail Description
highlights:added { id, text, color, note } Fired when a new highlight is created
highlights:removed { id } Fired when a highlight is deleted
highlights:note-changed { id, note } Fired when a note is added or edited
highlights:clicked { id } Fired when an existing highlight is clicked

JavaScript API

Related

  • <section> - For grouping related content within an article
  • <header> - For article title, author, date metadata
  • <footer> - For article attribution, related links, tags
  • <aside> - For tangentially related content like pull quotes
  • <address> - For author contact information