# Modern CSS in Markdown to PDF

HTML blocks read current CSS: custom properties, calc(), oklch() and color-mix(), nesting, cascade layers and :has(), drawn with shadows, gradients and transforms.

Custom properties, calc(), oklch() and color-mix(), nesting, cascade layers, :has() and ::first-letter, with shadows, gradients, opacity and transforms. Toggle: html_blocks.

- PDF: https://legivel.com/examples/text-structure/modern-css.pdf
- Page: https://legivel.com/examples/text-structure/modern-css
- Open in the editor: https://legivel.com/markdown-to-pdf?sample=html-css
- More markdown text and structure in PDF: https://legivel.com/examples/text-structure

## Markdown source

```markdown
# Modern CSS in HTML blocks

HTML blocks understand current CSS: variables, calc(), modern color spaces, nesting, cascade layers and Selectors Level 4. Effects such as shadows, gradients, rounded corners, opacity and transforms are drawn as vectors.

<div>
<style>
.card {
  --accent: oklch(55% 0.17 250);
  --pad: calc(8px + 0.5em);
  padding: var(--pad);
  border-radius: 12px / 8px;
  background: linear-gradient(135deg, #f8fafc, color-mix(in srgb, var(--accent) 12%, white));
  box-shadow: 0 4px 10px rgb(15 23 42 / 25%);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, white);
  margin-bottom: 14px;
  & h3 { margin: 0 0 6px; color: var(--accent); }
  & p::first-letter { font-size: 1.6em; font-weight: bold; color: var(--accent); }
}
.card:has(.tag) { border-width: 2px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: white; font-size: 11px; }
</style>
<div class="card"><h3>Variables, nesting and :has()</h3><p>This card takes its accent from a custom property in oklch(), mixes its background with color-mix(), sizes its padding with calc() and styles its first letter. Because it holds a tag, :has() gives it a thicker border. <span class="tag">new</span></p></div>
</div>

<div style="display:flex;gap:14px;align-items:center">
<div style="width:90px;height:90px;border-radius:50%;background:radial-gradient(circle at 30% 30%, #fde68a, #f97316 60%, #9a3412)"></div>
<div style="width:90px;height:90px;border-radius:16px;background:repeating-linear-gradient(45deg, #e0f2fe 0 8px, #bae6fd 8px 16px);border:2px dashed #0284c7"></div>
<div style="width:90px;height:90px;border-radius:8px;background:#7c3aed;opacity:0.55"></div>
<div style="width:90px;height:90px;border-radius:8px;background:hsl(160 70% 40%);transform:rotate(12deg) scale(0.9);box-shadow:inset 0 0 0 6px rgb(255 255 255 / 40%)"></div>
</div>

<div style="margin-top:16px;padding:10px 14px;border-radius:8px;background:#0f172a;color:#e2e8f0;text-shadow:0 1px 2px #000">Text shadow, a dark panel and an outline <span style="outline:2px solid #facc15;outline-offset:2px;padding:0 4px">around a word</span>.</div>

<div>
<style>
@layer base, theme;
@layer theme { li { color: #047857; } }
@layer base { li { color: #b91c1c; } }
ol.steps { counter-reset: step; list-style: none; padding: 0; }
ol.steps li { counter-increment: step; margin: 4px 0; }
ol.steps li::before { content: "Step " counter(step) " · "; font-weight: bold; }
li:is(.done) { text-decoration: line-through; color: #64748b; }
</style>
<ol class="steps"><li class="done">Collect the signed delivery notes</li><li>Match them against the invoices</li><li>Send the variance report</li></ol>
</div>

CSS the renderer does not draw is skipped with a note, never an error: the rest of the block still renders.
```
