<div class="actions">
  <button type="button" id="openDialogButton">Click Me</button>

<dialog id="myDialog">
  <section class="body">
    <p> Coffee, the world's favorite beverage, awakens the senses and fuels our lives. Made from roasted Coffea plant seeds, it offers complex flavors and aromas. Enjoyed as a morning ritual or a midday pick-me-up, coffee's energizing caffeine enhances focus and alertness, making it a cherished companion that brings people together and sparks creativity.</p>
    <p>Coffee is more than a drink; it's a cultural symbol and cherished ritual worldwide. From Italian espresso to Turkish coffee and artisanal pour-overs, each culture has its unique approach. Whether enjoyed black or infused with milk, spices, or syrups, coffee's versatility is undeniable. It sustains millions of livelihoods, from farmers to baristas, and as we savor its rich flavors, coffee ignites joy, connection, and fuels our daily endeavors.</p>
  <footer class="actions">
    <button type="button" id="closeDialogButton" autofocus>Close</button>
:root, ::backdrop {
  --primary: #577590;
  --primary-contrast: white;
  --accent: #F08A4B;
  --backdrop: rgba(242, 165, 65, .56);
  --text: #1a252f;

* { box-sizing: border-box }

html {
  margin: 0;
  padding: 0; 

body { 
  font-family: sans-serif;
  color: var(--text);

:where(h1, h2, h3, h4, h5, h6) { color: var(--primary) }

button {
  background: var(--primary);
  color: var(--primary-contrast);
  border: none;
  padding: .5rem 2rem;
  border-radius: 4px;
button:where(:focus, :focus-visible) {
  outline-offset: 2px;
  outline-color: var(--accent);

dialog::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(5px);

dialog[open] {
  display: grid;
  grid-template-rows: min-content auto min-content;
  width: 75svw;
  height: 75svh;
  padding: 0;
  border: none;
  border-radius: 4px;
  box-shadow: 0 0 10px var(--primary);
dialog > header {
  padding: .5rem 1rem;
  background: var(--primary);
  color: var(--primary-contrast);
  box-shadow: 2px 0 2px var(--primary)
dialog > header > h2 { 
  color: inherit;
  margin: 0;
dialog section.body { 
  overflow-y: auto;
  padding-left: 1rem;
  padding-right: 1rem;
dialog > footer {
  padding: .5rem 1rem;
  box-shadow: -2px 0 2px var(--primary);
(() => {
  'use strict'
  //  The dialog  
  const myDialog = document.getElementById('myDialog')

  //  Open and close buttons
  const openDialogButton = document.getElementById('openDialogButton')
  const closeDialogButton = document.getElementById('closeDialogButton')
  //  On click event listener that opens the dialog
  openDialogButton.addEventListener('click', () => {
    //  open the dialog
    //  put the focus on the close button
  //  On click event listener that closes the dialog
  closeDialogButton.addEventListener('click', () => {
    //  close the dialog

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.