Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.



  <h1>View Transition example 1</h1>

      <li><a href="#article1">Article 1</a></li>
      <li><a href="#article2">Article 2</a></li>


<main><div id="articleroot">

  <article id="article1">

    <h2>Article 1 content</h2>

      <img src="" width="800" height="500" alt="random" />
      <figcaption>photo credit:</figcaption>

    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam nulla tortor, facilisis vel mauris in, luctus semper turpis. Aliquam lobortis dolor in lacus convallis feugiat. Nulla aliquet ante laoreet enim maximus mollis.</p>

    <p>Donec luctus rhoncus ligula, quis porta massa pharetra eu. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam luctus ante finibus massa blandit, vel gravida mi egestas. Nunc ipsum tellus, luctus vel finibus in, venenatis at lectus.</p>

    <p>Aenean vestibulum turpis nisl, at suscipit nisi pellentesque vitae. Etiam maximus nulla vitae eleifend efficitur. Curabitur gravida orci vitae mauris sollicitudin ultricies nec eu lacus. Sed tellus purus, rhoncus ullamcorper ex ut, gravida mollis felis.</p>


  <article id="article2">

    <h2>Article 2 content</h2>

      <img src="" width="800" height="500" alt="random" />
      <figcaption>photo credit:</figcaption>

    <p>Ut pretium ac orci nec dictum. Suspendisse finibus lorem tincidunt, vehicula risus sit amet, rutrum ante. Morbi ac ante tellus. Nam id turpis in diam viverra eleifend. Phasellus auctor vitae diam et vehicula. Phasellus id dolor eu nibh commodo lacinia ut at enim.</p>

    <p>Vestibulum aliquam quis mauris sit amet elementum. Ut luctus tempus turpis, scelerisque suscipit risus tristique non. Maecenas sodales id nisi vitae vehicula.</p>




                :root {
  --color-fore: #333;
  --color-back: #fff;
  --color-head: #ccc;
  --color-link: #33f;

html {
  color: var(--color-fore);
  background-color: var(--color-back);

*, *::after, *::before {
  box-sizing: border-box;
  font-weight: 400;
  line-height: 1.6;
  padding: 0;
  margin: 0;

body {
  font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  font-size: clamp(1rem, calc(1rem + 0.5vw), 2.5rem);
  line-height: 1.5;

header {
  background-color: var(--color-head);
  padding-block: 0 0.5em;

header > div, main > div {
  max-width: 52rem;
  margin-inline: auto;
  padding-inline: 1rem;

nav ul {
  display: flex;
  gap: 0 1em;
  list-style-type: none;
  user-select: none;

main > div {
  margin-block-end: 2em;

article {
  scroll-margin-top: 10em;

figure {
  width: 100%;

img {
  width: 100%;
  height: auto;
  border: 1px solid var(--color-fore);

figcaption {
  font-size: 0.8em;
  font-style: italic;

h2, p {
  margin-block-start: 1em;

a:link, a:visited {
  color: var(--color-link);

::view-transition-new(root) {
  animation-duration: 1s;


                const article = document.getElementsByTagName('article');

document.body.addEventListener('click', e => {

  if (!e?.target?.hash) return;

  if (document.startViewTransition) {
    document.startViewTransition(() => switchArticle(e));
  else {


function switchArticle(e) {

  const hash = e?.target?.hash?.slice(1) || location?.hash?.slice(1);

  Array.from(article).forEach((a, i) => {

    if ( === hash || (!hash && !i)) {
    else {
      a.setAttribute('hidden', '');