article
Represents a self-contained composition intended for independent distribution or reuse.
Article
Self-contained content block with implicit padding.
Code
<article>
<h2>Title</h2>
<p>Content...</p>
</article>
Single-File, Classless, Themeable CSS for Semantic HTML
A classless, semantic style reset that styles HTML5 elements directly, providing accessible defaults without relying on utility-first CSS libraries or overly complex frameworks. It is themeable (via CSS custom properties) and designed for progressive enhancement, allowing further customization through classes, components, or frameworks when desired. By targeting semantic HTML, it provides a rock-solid, long-term foundation. All components are implemented according to the ARIA Authoring Practices Guide (APG), ensuring they are accessible, predictable, and keyboard-friendly, so your semantic HTML remains usable for everyone.
To get started, simply copy/paste the Before.css file into
your project and link to it in the head of your HTML document.
The following HTML5 elements are styled by Before Style:
Anchor element that creates a hyperlink to other pages, files, or locations.
A standard hyperlink with underline styling that inherits the current text color.
<a href="#">Click here to learn more</a>
Links that have been visited maintain the current color with slightly reduced opacity.
<a href="/previously-visited-page">Previously visited link</a>
Links with target="_blank" automatically display an external link indicator (↗).
<a href="https://example.com" target="_blank" rel="noopener noreferrer">Visit Example.com</a>
Links with the download attribute display a download indicator (↓) before the text.
<a href="/files/document.pdf" download>Download PDF</a>
Links with mailto: protocol display an email icon (✉) before the text.
<a href="mailto:hello@example.com">hello@example.com</a>
Links with tel: protocol display a phone icon (📞) before the text.
<a href="tel:+1234567890">+1 (234) 567-890</a>
Use aria-disabled="true" to visually disable a link while maintaining accessibility.
<a href="#" aria-disabled="true">Unavailable link</a>
Use aria-current="page" to indicate the current page in navigation. The link appears bold without underline.
<a href="/about" aria-current="page">About</a>
A hidden link that becomes visible on focus, allowing keyboard users to skip to main content.
<a href="#main-content">Skip to main content</a>
Represents an abbreviation or acronym with an optional title for the full description.
Dotted underline indicates hover for full text.
<abbr title="Full text">ABBR</abbr>
Provides contact information for the nearest article or body ancestor.
Italic contact information block.
<address>Contact info</address>
Defines a clickable area inside an image map.
Represents a self-contained composition intended for independent distribution or reuse.
Self-contained content block with implicit padding.
<article>
<h2>Title</h2>
<p>Content...</p>
</article>
Represents content tangentially related to the main content, often used for sidebars.
Sidebar or supplementary content with subtle styling.
<aside>
<!-- supplementary content -->
</aside>
Embeds sound content with controls for playback.
Full-width audio player with native controls.
<audio controls src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4
"></audio>
Represents text stylistically offset from normal text without conveying extra importance.
Bold text for stylistic offset.
<b>bold text</b>
Isolates a span of text that might be formatted in a different direction from surrounding text.
Isolates text direction from surrounding content.
<bdi>isolated text</bdi>
Overrides the current text directionality.
Forces text direction override.
<bdo dir="rtl">text</bdo>
Indicates an extended quotation from another source.
Indented with a left border to distinguish quoted content.
<blockquote>
<p>Quoted text here.</p>
</blockquote>
Represents the content of an HTML document.
Clean, readable defaults with system fonts, comfortable line height, and responsive max-width for optimal reading.
<body>
<h1>Page Title</h1>
<p>Content goes here.</p>
</body>
Produces a line break in text.
Forces a line break within text.
<br>
Container for graphics drawn via scripting (usually JavaScript).
Drawing surface with responsive sizing.
<canvas width="300" height="150"></canvas>
Specifies the title of a table.
Descriptive title displayed above the table.
<caption>Table title</caption>
Represents the title of a creative work being referenced.
Italic text for referencing creative works.
<cite>Work Title</cite>
Displays a fragment of computer code.
Inline code with subtle background for visibility.
<code>console.log()</code>
Wrap code in pre for multi-line code blocks.
<pre><code>function greet(name) {
return "Hello, " + name;
}</code></pre>
Defines a column within a table and is used for styling columns.
Groups one or more columns in a table for formatting.
Links content with a machine-readable translation.
Machine-readable value with human display.
<data value="123">Display</data>
Contains a set of option elements representing predefined options for an input.
Provides autocomplete options for an input.
<datalist id="list">
<option value="Option">
</datalist>
Provides the description or value for a term in a description list.
Indented description for a term.
<dd>Description text</dd>
Represents text that has been deleted from a document.
Strikethrough styling to indicate removed content.
<del>deleted text</del>
Creates a disclosure widget from which the user can obtain additional information.
Expandable content with toggle control.
<details>
<summary>Title</summary>
<p>Content...</p>
</details>
Indicates the defining instance of a term.
Italic styling for terms being defined.
<dfn>term</dfn>
A generic container for flow content with no semantic meaning.
Generic block-level container.
<div>content</div>
Represents a description list of term-description pairs.
A list of terms and their descriptions, perfect for glossaries or metadata.
<dl>
<dt>Term</dt>
<dd>Definition</dd>
</dl>
Specifies a term in a description list.
Bold term in a definition list.
<dt>Term</dt>
Marks text with stress emphasis.
Italic text for stress emphasis.
<em>emphasized text</em>
Embeds external content from an external application or plugin.
Groups related elements within a form.
Bordered container for grouping related form fields.
<fieldset>
<legend>Group Title</legend>
<!-- form fields -->
</fieldset>
Represents a caption or legend for a figure.
Smaller, muted text for describing figure content.
<figcaption>Caption text</figcaption>
Represents self-contained content with an optional caption.
Image container with descriptive caption below.
<figure>
<img src="image.jpg" alt="Alt">
<figcaption>Caption</figcaption>
</figure>
Represents a section containing interactive controls for submitting information.
A simple form with inputs and a submit button.
<form>
<label>Name</label>
<input type="text">
<button type="submit">Submit</button>
</form>
Represents the highest level section heading.
The main heading of the page. Bold and large for clear hierarchy.
<h1>Main Page Title</h1>
Represents a second-level section heading.
Major section heading at 2rem size.
<h2>Heading Text</h2>
Represents a third-level section heading.
Subsection heading at 1.5rem size.
<h3>Heading Text</h3>
Represents a fourth-level section heading.
Minor heading at 1.25rem size.
<h4>Heading Text</h4>
Represents a fifth-level section heading.
Small heading at 1rem size.
<h5>Heading Text</h5>
Represents the lowest level section heading.
Smallest heading at 0.875rem size.
<h6>Heading Text</h6>
Contains machine-readable metadata about the document.
Represents introductory content or navigational aids for a section or page.
Introductory content container.
<header>
<h1>Title</h1>
</header>
Groups a heading with related content such as subheadings.
Groups heading with subtitle, reduced spacing between.
<hgroup>
<h1>Title</h1>
<p>Subtitle</p>
</hgroup>
Represents a thematic break between paragraph-level elements.
A subtle line to separate content sections.
<hr>
The root element of an HTML document.
Represents text in an alternate voice or mood, such as technical terms or foreign phrases.
Italic text for alternate voice or mood.
<i>italic text</i>
Embeds another HTML page within the current page.
Embedded frame with no border.
<iframe src="url" title="Description"></iframe>
Embeds an image into the document.
Responsive image that scales to its container.
<img src="image.jpg" alt="Description">
Creates interactive form controls for accepting user data.
Standard text input with clean borders and focus state.
<input type="text" placeholder="Enter text...">
Checkbox input using system accent color.
<input type="checkbox">
Radio button for single selection from a group.
<input type="radio" name="group">
Represents text that has been added to a document.
Underlined to indicate newly added content.
<ins>inserted text</ins>
Represents user keyboard input.
Styled like a physical keyboard key with border and shadow.
<kbd>Ctrl</kbd>
Represents a caption for an item in a user interface.
Block-level label with subtle weight.
<label>Field label</label>
Represents a caption for a fieldset.
Caption displayed on fieldset border.
<legend>Group Title</legend>
Represents an item in a list.
Individual list items with comfortable spacing.
<li>List item content</li>
Represents the dominant content of the body of a document.
Primary content area of the document.
<main>
<!-- primary content -->
</main>
Defines an image map with clickable areas.
Represents text marked or highlighted for reference or notation.
Yellow highlight for marking relevant content.
<mark>highlighted text</mark>
Represents metadata that cannot be expressed with other HTML elements.
Defines content to display when scripts are not supported or disabled.
Represents an external resource such as an image, plugin, or nested browsing context.
Represents an ordered list of items.
A numbered list for sequential content.
<ol>
<li>First step</li>
<li>Second step</li>
<li>Third step</li>
</ol>
Groups related options within a select element.
Groups options with a bold label.
<optgroup label="Group">
<option>Item</option>
</optgroup>
Represents an option in a select element or datalist.
Selectable item within a dropdown.
<option value="val">Label</option>
Container for the result of a calculation or user action.
Displays calculation results inline.
<output>result</output>
Represents a paragraph of text.
Standard paragraph with comfortable line height and spacing.
<p>This is a paragraph of text.</p>
Contains source elements and one img element for responsive images.
Responsive image container for multiple sources.
<picture>
<source srcset="https://picsum.photos/seed/button/800/400.webp" type="image/webp">
<img src="https://picsum.photos/seed/button/400/200" alt="Alt">
</picture>
Represents preformatted text preserving whitespace and line breaks.
Preserves whitespace and uses monospace font with subtle background.
<pre>Preformatted text here</pre>
Displays the completion progress of a task.
Visual progress indicator using the primary color.
<progress value="70" max="100"></progress>
Represents a short inline quotation.
Automatically wrapped with quotation marks.
<q>Quoted text</q>
Provides fallback parentheses for browsers that don't support ruby annotations.
Fallback parentheses for non-ruby browsers.
<rp>(</rp>
Specifies the ruby text component of a ruby annotation.
Small annotation text above base character.
<rt>annotation</rt>
Represents a ruby annotation for showing pronunciation of East Asian characters.
Shows pronunciation above characters.
<ruby>
字 <rt>pronunciation</rt>
</ruby>
Represents text that is no longer accurate or relevant.
Text with line through indicating outdated content.
<s>old text</s>
Represents sample output from a computer program.
Monospace font for computer output.
<samp>output text</samp>
Embeds or references executable JavaScript code.
Represents a standalone section of a document.
Thematic grouping of content.
<section>
<h2>Heading</h2>
<p>Content...</p>
</section>
Represents a control providing a menu of options.
Dropdown menu for selecting from predefined options.
<select>
<option>Option 1</option>
<option>Option 2</option>
</select>
A placeholder inside a web component for custom markup.
Represents side comments or small print.
Reduced font size for fine print or disclaimers.
<small>fine print</small>
Specifies multiple media resources for picture, audio, or video elements.
A generic inline container for phrasing content.
Generic inline container.
<span>inline</span>
Indicates text with strong importance or urgency.
Bold text for emphasis and importance.
<strong>important text</strong>
Contains CSS styling information for a document.
Represents subscript text.
Text positioned below the baseline.
H<sub>2</sub>O
Specifies a visible heading for a details element.
Clickable heading that toggles the details content.
<summary>Toggle heading</summary>
Represents superscript text.
Text positioned above the baseline.
x<sup>2</sup>
Groups the body content rows of a table.
Container for table body rows.
<tbody>
<tr><td>Data</td></tr>
</tbody>
Represents a data cell in a table.
Standard data cell with padding and border.
<td>Cell data</td>
Holds HTML content that is not rendered but can be instantiated via JavaScript.
Represents a multi-line plain text editing control.
Multi-line input with resizable height.
<textarea placeholder="Enter text..."></textarea>
Groups the footer content rows of a table.
Container for table footer rows, often for totals.
<tfoot>
<tr><td>Footer</td></tr>
</tfoot>
Represents a header cell in a table.
Bold header cell with bottom border.
<th>Header</th>
Groups the header content rows of a table.
Container for table header rows.
<thead>
<tr><th>Header</th></tr>
</thead>
Represents a specific period in time or a machine-readable datetime.
Machine-readable date/time with human display.
<time datetime="2024-01-15">Jan 15</time>
Defines the document title shown in the browser tab.
Represents a row of cells in a table.
Horizontal row containing table cells.
<tr><td>Cell</td></tr>
Specifies timed text tracks for media elements.
Represents text with an unarticulated annotation, such as misspelled words.
Wavy underline for annotated text like spelling errors.
<u>annotated text</u>
Represents an unordered list of items.
A bullet list with proper spacing and indentation.
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
Lists can be nested for hierarchical content.
<ul>
<li>Parent item
<ul>
<li>Child item</li>
</ul>
</li>
</ul>
Represents the name of a variable in a mathematical or programming context.
Italic monospace for variable names.
<var>variableName</var>
Embeds video content with playback controls.
Responsive video with native controls.
<video controls src="https://storage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
"></video>
Represents an optional line break opportunity.
Suggests where a line break may occur.
long<wbr>word
The following ARIA components are styled by Before Style:
A vertically stacked set of interactive headings that each reveal a section of content.
A simple accordion using native details/summary elements with exclusive behavior via the name attribute.
An accordion is a vertically stacked set of interactive headings that each reveal a section of content.
Use accordions when you have multiple sections of content that users may want to browse through without leaving the page.
Yes, when built with native details/summary elements, accordions are keyboard navigable and screen reader friendly.
<div role="region" aria-label="FAQ">
<details name="accordion-group">
<summary>Section Title</summary>
<p>Section content...</p>
</details>
<details name="accordion-group">
<summary>Another Section</summary>
<p>More content...</p>
</details>
</div>
An accordion where one panel starts expanded using the open attribute.
<nav aria-label="Categories">
<details name="nav-accordion" open>
<summary>First Section (Open)</summary>
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
</details>
<details name="nav-accordion">
<summary>Second Section</summary>
<ul>
<li>Item 3</li>
<li>Item 4</li>
</ul>
</details>
</nav>
Accordions can be nested to create hierarchical content structures.
Run npm install to get started with the project.
Edit the config file to customize your setup.
Learn about available component APIs.
Explore utility functions and helpers.
<section aria-labelledby="section-title">
<h3 id="section-title">Section Title</h3>
<details name="parent-accordion">
<summary>Parent Item</summary>
<details>
<summary>Child Item</summary>
<p>Nested content...</p>
</details>
</details>
</section>
A live region that displays important, time-sensitive information to the user.
A rotating set of content items that can be navigated through sequentially.
A form control that allows users to select one or more options from a set.
A composite widget combining a text input with a popup listbox for selecting values.
A modal or non-modal window that appears above the page content requiring user interaction.
A button that controls the visibility of a section of content.
A scrollable list of articles where new content may be added as the user scrolls.
An interactive two-dimensional data structure with rows and columns of cells.
A container for introductory content or navigational aids at the top of a page or section.
Semantic regions that help assistive technology users navigate and understand page structure.
An interactive reference to a resource that navigates the user when activated.
A widget that allows users to select one or more items from a list of choices.
A graphical display of a numeric value within a known range.
A group of mutually exclusive options where only one can be selected at a time.
An input control that allows users to select a value from a range by dragging a thumb.
A toggle control that represents an on/off or enabled/disabled state.
A structured grid of data organized in rows and columns for displaying information.
A set of layered content panels where only one panel is displayed at a time.
A container for grouping related controls such as buttons and menu items.
A contextual popup that displays descriptive information about an element on hover or focus.
A hierarchical list that can have nested groups of items that can be expanded or collapsed.
A grid widget that combines the features of a tree and a data grid.
A movable divider that separates two sections and allows resizing them.