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>Creating a Slide Deck with Just HTML and CSS</h1>
    <h2>CSS Scroll Snap</h2>
    <p>Scroll snap allows us to create slides based on child elements of a scroll container.</p>
    <h2>Counting Slides with CSS Counters</h2>
    <p>We can use CSS counters to number the slides. This can be included in layouts.</p>
    <h2>Using CSS Grid to Create Layouts</h2>
    <p>CSS grid allows us to create slide layouts with ease.</p>


                /* Border-box all the things */
* {
  box-sizing: border-box;

/* Cover the whole screen */
body {
  block-size: 100%;

/* This is the slide deck */
article {
  /* Cover the screen */
  block-size: 100%;
  /* Make it a flex container */
  display: flex;
  /* Make it a scroll container */
  overflow-x: scroll;
  /* Make inline scrolling snap */
  scroll-snap-type: x mandatory;
  /* Use inline axis for scrolling where supported */
  @supports (overflow-inline: scroll) {
    overflow-inline: scroll;
    scroll-snap-type: inline mandatory;
  /* Set up a slide counter */
  counter-reset: slide;

/* These are the slides */
article > * {
  /* Fill the scroll container */
  flex: 0 0 100%;
  /* Scroll to the start of the slide */
  scroll-snap-align: start;
  /* Increment the slide counter */
  counter-increment: slide;

/* This is the counter */
article > ::before {
  /* Display the counter */
  content: counter(slide);

/* This is a cover layout for the first slide */
article > :first-child {
  display: grid;
  place-content: center;
  text-align: center;
  padding-inline: 4rem;
  font-size: clamp(1rem, 1rem + 2vw, 3rem);
  line-height: 1.3;

 Presentational styles (not required for the technique) 

:root {
  --foreground: #000;
  --background: #fff;

@media (prefers-color-scheme: dark) {
  :root {
    --foreground: #fff;
    --background: #000;

body {
  margin: 0;
  font-family: Avenir Next, system-ui;
  background-color: var(--background);
  color: var(--foreground);

article {
  scrollbar-color: var(--foreground) transparent;
  scrollbar-width: thin;

/* Make each slide a grid layout */
article > * {
  position: relative;
  display: grid;
  grid-auto-flow: row;
  grid-template-rows: max-content;
  row-gap: 1rem;
  padding: 2rem;
  font-size: 1.5rem;

/* Style the slide counter */
article > ::before {
  position: absolute;
  inset-block-start: 1rem;
  inset-inline-end: 1rem;
  padding: 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  font-variant: tabular-nums;
  line-height: 1;
  background-color: var(--foreground);
  color: var(--background);
  clip-path: circle();

/* Remove margin for slide content */
article > * > * {
  margin: 0;

/* For all none cover layouts set the heading size */
article > * + * > :first-child {
  font-size: 2em;

/* For the cover layout set the measure */
article > :first-child > :first-child {
  max-inline-size: 21ch;