Resource Cards in HTML, CSS and vanilla JS
A copy-paste Resource Cards in plain HTML and CSS, with vanilla JavaScript: no framework, no build step, MIT-licensed.
Live preview
Source (copy-ready)
<section class="example-resource-cards" data-dcl-layout="rail" data-dcl-scheme="light" aria-labelledby="example-resource-cards-title"><header><h2 id="example-resource-cards-title">Resource Cards</h2></header><div class="parts"><article><h3>Project brief</h3><p>Read the scope and constraints.</p></article><article><h3>Research notes</h3><p>See interview summaries.</p></article><article><h3>Design files</h3><p>Find the latest approved mockups.</p></article></div>
<script>
(() => {
const root = document.currentScript.closest(".example-resource-cards");
const instance = Array.from(document.getElementsByClassName("example-resource-cards")).indexOf(root);
if (instance > 0) {
const references = ["id", "aria-labelledby", "aria-controls", "aria-describedby", "for", "name"];
for (const element of [root, ...root.querySelectorAll("*")]) {
for (const attr of references) {
if (element.hasAttribute(attr)) element.setAttribute(attr, element.getAttribute(attr) + "--" + instance);
}
const href = element.getAttribute("href");
if (href && href.startsWith("#")) element.setAttribute("href", href + "--" + instance);
}
}
const preference = matchMedia("(prefers-color-scheme: dark)");
const apply = () => { root.dataset.dclScheme = preference.matches ? "dark" : "light"; };
preference.addEventListener("change", apply);
apply();
})();
</script></section>
<style>
.example-resource-cards { color: #11292f; background-color: #ffffff; color-scheme: light; }
.example-resource-cards a { color: #005c62; }
.example-resource-cards button, .example-resource-cards summary, .example-resource-cards input, .example-resource-cards select {
color: #11292f; background-color: #e4edef; border-color: #697f84;
}
.example-resource-cards button:hover, .example-resource-cards summary:hover, .example-resource-cards button[aria-selected="true"] {
color: #ffffff; background-color: #00535a;
}
.example-resource-cards dialog { color: #11292f; background-color: #ffffff; }
.example-resource-cards [data-note] { color: #11292f; background-color: #e4edef; }
.example-resource-cards :focus-visible { outline: 3px solid #005c62; outline-offset: 2px; }
.example-resource-cards[data-dcl-scheme="dark"] { color: #eff8f9; background-color: #142f36; color-scheme: dark; }
.example-resource-cards[data-dcl-scheme="dark"] a { color: #8fe1da; }
.example-resource-cards[data-dcl-scheme="dark"] button, .example-resource-cards[data-dcl-scheme="dark"] summary, .example-resource-cards[data-dcl-scheme="dark"] input, .example-resource-cards[data-dcl-scheme="dark"] select {
color: #eff8f9; background-color: #1c3c44; border-color: #839fa5;
}
.example-resource-cards[data-dcl-scheme="dark"] button:hover, .example-resource-cards[data-dcl-scheme="dark"] summary:hover, .example-resource-cards[data-dcl-scheme="dark"] button[aria-selected="true"] {
color: #11292f; background-color: #8fe1da;
}
.example-resource-cards[data-dcl-scheme="dark"] dialog { color: #eff8f9; background-color: #142f36; }
.example-resource-cards[data-dcl-scheme="dark"] [data-note] { color: #eff8f9; background-color: #1c3c44; }
.example-resource-cards[data-dcl-scheme="dark"] :focus-visible { outline: 3px solid #8fe1da; outline-offset: 2px; }
.example-resource-cards, .example-resource-cards * { box-sizing: border-box; }
.example-resource-cards { font: 1rem/1.5 system-ui, sans-serif; padding: 1rem; border-radius: 0.75rem; overflow-wrap: anywhere; }
.example-resource-cards h2, .example-resource-cards h3 { line-height: 1.15; margin-block: 0 0.75rem; }
.example-resource-cards p { margin-block: 0.5rem; }
.example-resource-cards ul { margin-block: 0.5rem; padding-inline-start: 1.5rem; }
.example-resource-cards article, .example-resource-cards details, .example-resource-cards [data-note] { border: 1px solid; border-radius: 0.375rem; padding: 0.75rem; }
.example-resource-cards button, .example-resource-cards summary, .example-resource-cards input, .example-resource-cards select {
min-block-size: 44px; border: 1px solid; border-radius: 0.375rem; padding: 0.5rem 0.75rem; font: inherit;
}
.example-resource-cards button, .example-resource-cards summary { cursor: pointer; transition: background-color 140ms ease-out; }
.example-resource-cards button:disabled { cursor: not-allowed; text-decoration: line-through; }
.example-resource-cards input { display: block; inline-size: 100%; }
.example-resource-cards dialog { max-inline-size: min(32rem, 90vw); border-radius: 0.75rem; padding: 1rem; }
.example-resource-cards th, .example-resource-cards td { padding: 0.5rem; text-align: start; border-block-end: 1px solid; }
.example-resource-cards table { border-collapse: collapse; inline-size: 100%; }
.example-resource-cards caption { font-weight: bold; text-align: start; }
.example-resource-cards dt { font-weight: 600; }
.example-resource-cards dd { margin: 0 0 0.75rem; }
.example-resource-cards [hidden] { display: none !important; }
.example-resource-cards .parts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 1rem; align-items: start; }
@media (max-width: 30rem) {
.example-resource-cards[data-dcl-layout="rail"] .parts { grid-template-columns: minmax(0, 1fr); }
.example-resource-cards[data-dcl-layout="rail"] .parts > :is(p, ul, article) { grid-column: 1; grid-row: auto; }
.example-resource-cards[data-dcl-layout="rail"] .parts > :is(details, nav) { grid-row: auto; }
}
@media (prefers-reduced-motion: reduce) { .example-resource-cards * { transition: none !important; } }
</style>
When to use
Use this rail arrangement when a sidebar can share space with the main content.
Avoid
Prefer a plain list or table for dense, uniform facts.
Accessibility
Keep heading levels in order and do not depend on the card boundary for meaning.
Was this useful? Send feedback.