Component Library

← Back to gallery

Workshop Hero in HTML, CSS and vanilla JS

A copy-paste Workshop Hero in plain HTML and CSS, with vanilla JavaScript: no framework, no build step, MIT-licensed.

Category: Marketing · Tags: hero section, split, hero, landing

Live preview

Source (copy-ready)

<section class="example-workshop-hero" data-dcl-layout="split" data-dcl-scheme="light" aria-labelledby="example-workshop-hero-title"><header><h2 id="example-workshop-hero-title">Workshop Hero</h2></header><div class="parts"><p>Build a responsive page with HTML and CSS in one afternoon.</p><a href="#example-workshop-hero-start">View the agenda</a><ul id="example-workshop-hero-start"><li><strong>Hands-on</strong> Bring a small example to work on.</li><li><strong>Prototypes</strong> Take your work home with you.</li></ul></div>
<script>
(() => {
  const root = document.currentScript.closest(".example-workshop-hero");
  const instance = Array.from(document.getElementsByClassName("example-workshop-hero")).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-workshop-hero { color: #11292f; background-color: #ffffff; color-scheme: light; }
.example-workshop-hero a { color: #005c62; }
.example-workshop-hero button, .example-workshop-hero summary, .example-workshop-hero input, .example-workshop-hero select {
  color: #11292f; background-color: #e4edef; border-color: #697f84;
}
.example-workshop-hero button:hover, .example-workshop-hero summary:hover, .example-workshop-hero button[aria-selected="true"] {
  color: #ffffff; background-color: #00535a;
}
.example-workshop-hero dialog { color: #11292f; background-color: #ffffff; }
.example-workshop-hero [data-note] { color: #11292f; background-color: #e4edef; }
.example-workshop-hero :focus-visible { outline: 3px solid #005c62; outline-offset: 2px; }


.example-workshop-hero[data-dcl-scheme="dark"] { color: #eff8f9; background-color: #142f36; color-scheme: dark; }
.example-workshop-hero[data-dcl-scheme="dark"] a { color: #8fe1da; }
.example-workshop-hero[data-dcl-scheme="dark"] button, .example-workshop-hero[data-dcl-scheme="dark"] summary, .example-workshop-hero[data-dcl-scheme="dark"] input, .example-workshop-hero[data-dcl-scheme="dark"] select {
  color: #eff8f9; background-color: #1c3c44; border-color: #839fa5;
}
.example-workshop-hero[data-dcl-scheme="dark"] button:hover, .example-workshop-hero[data-dcl-scheme="dark"] summary:hover, .example-workshop-hero[data-dcl-scheme="dark"] button[aria-selected="true"] {
  color: #11292f; background-color: #8fe1da;
}
.example-workshop-hero[data-dcl-scheme="dark"] dialog { color: #eff8f9; background-color: #142f36; }
.example-workshop-hero[data-dcl-scheme="dark"] [data-note] { color: #eff8f9; background-color: #1c3c44; }
.example-workshop-hero[data-dcl-scheme="dark"] :focus-visible { outline: 3px solid #8fe1da; outline-offset: 2px; }

.example-workshop-hero, .example-workshop-hero * { box-sizing: border-box; }
.example-workshop-hero { font: 1rem/1.5 system-ui, sans-serif; padding: 1rem; border-radius: 0.75rem; overflow-wrap: anywhere; }
.example-workshop-hero h2, .example-workshop-hero h3 { line-height: 1.15; margin-block: 0 0.75rem; }
.example-workshop-hero p { margin-block: 0.5rem; }
.example-workshop-hero ul { margin-block: 0.5rem; padding-inline-start: 1.5rem; }
.example-workshop-hero article, .example-workshop-hero details, .example-workshop-hero [data-note] { border: 1px solid; border-radius: 0.375rem; padding: 0.75rem; }
.example-workshop-hero button, .example-workshop-hero summary, .example-workshop-hero input, .example-workshop-hero select {
  min-block-size: 44px; border: 1px solid; border-radius: 0.375rem; padding: 0.5rem 0.75rem; font: inherit;
}
.example-workshop-hero button, .example-workshop-hero summary { cursor: pointer; transition: background-color 140ms ease-out; }
.example-workshop-hero button:disabled { cursor: not-allowed; text-decoration: line-through; }
.example-workshop-hero input { display: block; inline-size: 100%; }
.example-workshop-hero dialog { max-inline-size: min(32rem, 90vw); border-radius: 0.75rem; padding: 1rem; }
.example-workshop-hero th, .example-workshop-hero td { padding: 0.5rem; text-align: start; border-block-end: 1px solid; }
.example-workshop-hero table { border-collapse: collapse; inline-size: 100%; }
.example-workshop-hero caption { font-weight: bold; text-align: start; }
.example-workshop-hero dt { font-weight: 600; }
.example-workshop-hero dd { margin: 0 0 0.75rem; }
.example-workshop-hero [hidden] { display: none !important; }
.example-workshop-hero .parts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: 1rem; }
.example-workshop-hero .parts > ul { grid-column: 1 / -1; columns: 2; } .example-workshop-hero .parts > a { justify-self: start; align-self: center; }
@media (max-width: 30rem) {
  .example-workshop-hero[data-dcl-layout="rail"] .parts { grid-template-columns: minmax(0, 1fr); }
  .example-workshop-hero[data-dcl-layout="rail"] .parts > :is(p, ul, article) { grid-column: 1; grid-row: auto; }
  .example-workshop-hero[data-dcl-layout="rail"] .parts > :is(details, nav) { grid-row: auto; }
}
@media (prefers-reduced-motion: reduce) { .example-workshop-hero * { transition: none !important; } }
</style>

When to use

Use this split arrangement when readers benefit from seeing items side by side.

Avoid

Keep the primary action distinct and avoid repeating the entire page in the hero.

Accessibility

Use a real link with action-oriented text and keep the heading in the document hierarchy.

Was this useful? Send feedback.