Styled Definition List Template
A clean and structured template for presenting glossary terms, metadata, or product specifications.
This component styles the native HTML definition list, aligning terms and their definitions in a highly readable two-column grid on larger screens.
About this Template
The definition list is a powerful but often overlooked HTML element. This template uses a semantic definition list (dl) with its corresponding term (dt) and definition (dd) elements. For smaller screens, it displays as a stacked list. For larger screens, a media query applies a CSS Grid layout, elegantly arranging the terms and definitions into two distinct columns for easy scanning.
Features
- Perfectly Semantic: Uses the correct HTML elements (
dl,dt,dd) for their intended purpose. - Responsive Grid Layout: Mobile-first stacking transforms into a clean two-column grid on desktops.
- Self-Contained Code: All styles are scoped to the
.styled-dl-templateclass to avoid conflicts. - Easy to Customize: Fonts, colors, and layout ratios can be easily changed with CSS variables.
Code Breakdown
The structure consists of a dl element with a class of .definition-list. On small screens, no special layout is applied; the browser's default block-level display for the dt and dd creates a simple, stacked appearance.
A media query for screens wider than 768px applies display: grid to the .definition-list container. The rule grid-template-columns: 1fr 2fr (or similar) is used to divide the space into two columns. The terms (dt) automatically occupy the first column and the definitions (dd) the second, creating the side-by-side layout.
Code
Here's the full code for the template: