Syntax-Highlighted Code
A code block with real syntax highlighting, via Prism.
Requires Bootstrap 5, Prism. Add the CDN tags below to your page (styles in
<head>, scripts before </body>). The downloaded file already includes them.<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/themes/prism-tomorrow.min.css"><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script><script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/prism.min.js"></script><div class="card border-0 shadow" style="width:400px;max-width:100%"><pre class="mb-0 rounded"><code class="language-javascript">const greet = (name) => {
return `Hello, ${name}!`;
};
console.log(greet('World'));</code></pre></div>Prism.highlightAll();Free to use.This component uses Bootstrap 5, Prism (linked above). Copy any file, or download a ready-to-open .html page with the CDN links already included.