Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <div class="content-container">
  <header>
    <h1>Markup Is Functional, Not Visual</h1>
    <h2>Links and Buttons</h2>
  </header>
  <main>
    <p>A wonderful thing about design is its ability to transform rudimentary tasks and elements into appealing and adaptive design languages. However, the way something looks is not always indicative to how it works.</p>

    <!-- ANCHOR DEMO //-->
    <section class="content-section">
      <h3>Using an <code class="inline">anchor</code> to navigate</h3>
      <p class="col-span">When navigating with a link, the element can be focused, the url can be previewed while hovering/focusing, the url can be copied and the page can be opened in a new tab or window.</p>
      <a href="/#" class="nav-element">
        <svg xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 512 512" role="presentation">
          <polyline points="328 112 184 256 328 400" style="fill:none;stroke:current-color;stroke-linecap:round;stroke-linejoin:round;stroke-width:48px" />
        </svg>
        <span>Back</span>
      </a>

    </section>

    <!-- BUTTON DEMO //-->
    <section class="content-section">
      <h3>Using a <code class="inline">button</code> to navigate</h3>
      <p class="col-span">However, when navigating with a <code class="inline">button</code>, that expected functionality is lost.</p>
      <button class="nav-element" type="button" onclick="window.history.go(-1); return false;">

        <svg xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 512 512" role="presentation">
          <polyline points="328 112 184 256 328 400" style="fill:none;stroke:current-color;stroke-linecap:round;stroke-linejoin:round;stroke-width:48px" />
        </svg>
        <span>Back</span>
      </button>

    </section>

    <!-- DIV DEMO //-->
    <section class="content-section">
      <h3>Using a <code class="inline">div</code> to navigate</h3>
      <p class="col-span">Saving the worst for last. When navigating with a <code class="inline">div</code>, all native and expected operability is lost. The element cannot natively be focused and the native cursor does not indicate interactivity. This is only operable by a traditional mouse click.</p>
      <div class="nav-element" onclick="window.history.go(-1); return false;">

        <svg xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 512 512" role="presentation">
          <polyline points="328 112 184 256 328 400" style="fill:none;stroke:current-color;stroke-linecap:round;stroke-linejoin:round;stroke-width:48px" />
        </svg>
        <span>Back</span>
      </div>

    </section>
  </main>
  <footer>
    <p>Keys To An Accessibility Mindset</p>
    <a href="https://twitter.com/DanielYuschick" aria-label="@Daniel Yuschick on Twitter">@DanielYuschick</a>
  </footer>
</div>
              
            
!

CSS

              
                .nav-element {
  align-items: center;
  background: var(--color-core-primary);
  display: inline-flex;
  gap: var(--space-base-2x);
  padding: var(--space-base-1x) var(--space-base-3x);
  border-radius: var(--space-base-1x);
  text-decoration: none;
  block-size: 50px;
  font-weight: 600;

  &:hover,
  &:focus {
    text-decoration: underline;
    background: var(--color-core-secondary);
    color: var(--color-aux-950);
  }
}

/**********
*** SETUP
**********/
/***** Properties *****/
:root {
  --color-aux-50: rgb(10, 10, 11);
  --color-aux-100: rgb(29, 29, 32);
  --color-aux-200: rgb(48, 48, 54);
  --color-aux-300: rgb(77, 77, 86);
  --color-aux-400: rgb(96, 96, 108);
  --color-aux-500: rgb(115, 115, 130);
  --color-aux-600: rgb(147, 147, 159);
  --color-aux-700: rgb(169, 169, 178);
  --color-aux-800: rgb(190, 190, 197);
  --color-aux-900: rgb(223, 223, 226);
  --color-aux-950: rgb(242, 239, 233);

  --color-core-primary: #f6aa1c;
  --color-core-secondary: #621708;
  --color-core-tertiary: #bc3908;

  --font-family-body: "Inter", sans-serif;
  --font-family-heading: "Sofia Sans", sans-serif;

  --space-base: 4px;
  --space-base-half: calc(var(--space-base) / 2);
  --space-base-1x: var(--space-base);
  --space-base-2x: calc(var(--space-base) * 2);
  --space-base-3x: calc(var(--space-base) * 3);
  --space-base-4x: calc(var(--space-base) * 4);
  --space-base-6x: calc(var(--space-base) * 6);
  --space-base-8x: calc(var(--space-base) * 8);
  --space-base-12x: calc(var(--space-base) * 12);
  --space-base-16x: calc(var(--space-base) * 16);
  --space-base-24x: calc(var(--space-base) * 24);
}

/***** Landmarks *****/
body {
  /* background by SVGBackgrounds.com */
  background-color: var(--color-aux-950);

  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2000 1500'%3E%3Cdefs%3E%3Crect fill='none' stroke-width='1' id='a' x='-400' y='-300' width='800' height='600'/%3E%3C/defs%3E%3Cg style='transform-origin:center'%3E%3Cg transform='rotate(93.6 0 0)' style='transform-origin:center'%3E%3Cg transform='rotate(-160 0 0)' style='transform-origin:center'%3E%3Cg transform='translate(1000 750)'%3E%3Cuse stroke='%23F2F4F3' href='%23a' transform='rotate(10 0 0) scale(2.1)'/%3E%3Cuse stroke='%23f2efe5' href='%23a' transform='rotate(20 0 0) scale(2.2)'/%3E%3Cuse stroke='%23f3ead6' href='%23a' transform='rotate(30 0 0) scale(2.3)'/%3E%3Cuse stroke='%23f3e5c8' href='%23a' transform='rotate(40 0 0) scale(2.4)'/%3E%3Cuse stroke='%23f3e0ba' href='%23a' transform='rotate(50 0 0) scale(2.5)'/%3E%3Cuse stroke='%23f3dbab' href='%23a' transform='rotate(60 0 0) scale(2.6)'/%3E%3Cuse stroke='%23f4d69d' href='%23a' transform='rotate(70 0 0) scale(2.7)'/%3E%3Cuse stroke='%23f4d18f' href='%23a' transform='rotate(80 0 0) scale(2.8)'/%3E%3Cuse stroke='%23f4cd80' href='%23a' transform='rotate(90 0 0) scale(2.9)'/%3E%3Cuse stroke='%23f4c872' href='%23a' transform='rotate(100 0 0) scale(3)'/%3E%3Cuse stroke='%23f5c364' href='%23a' transform='rotate(110 0 0) scale(3.1)'/%3E%3Cuse stroke='%23f5be55' href='%23a' transform='rotate(120 0 0) scale(3.2)'/%3E%3Cuse stroke='%23f5b947' href='%23a' transform='rotate(130 0 0) scale(3.3)'/%3E%3Cuse stroke='%23f5b439' href='%23a' transform='rotate(140 0 0) scale(3.4)'/%3E%3Cuse stroke='%23f6af2a' href='%23a' transform='rotate(150 0 0) scale(3.5)'/%3E%3Cuse stroke='%23F6AA1C' href='%23a' transform='rotate(160 0 0) scale(3.6)'/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  background-attachment: fixed;
  background-size: cover;
  background-position: center center;
  display: grid;
  align-content: center;
}

footer {
  --padding-offset: var(--space-base-4x);

  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  border-block-start: 1px solid #000;
  padding-block: var(--padding-offset);
  margin-block-start: var(--padding-offset);
}

/***** Textual *****/
a,
a:visited,
a:active,
a:link {
  color: var(--color-aux-50);

  &:not(.nav-element):hover {
    background: var(--color-aux-800);
  }
}

span,
p {
  font-family: var(--font-family-body);
}

p + p {
  margin-block-start: 1rem;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-family-heading);
}

code {
  background: var(--color-aux-100);
  color: var(--color-aux-950);
  display: block;
  padding: 0.25rem 0.5rem;

  &.inline {
    display: inline-block;
  }
}

/***** Other *****/
.content-container {
  inline-size: 75%;
  margin-inline: auto;
}

/**********
*** RESET
**********/
* {
  margin: 0;
  padding: 0;
}

*,
::before,
::after {
  box-sizing: border-box;
}

*:where(:not(fieldset, progress, meter)) {
  background-origin: border-box;
  background-repeat: no-repeat;
  border-style: solid;
  border-width: 0;
}

html {
  -webkit-text-size-adjust: none;
  block-size: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html:focus-within {
    scroll-behavior: smooth;
  }
}

body {
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  min-block-size: 100%;
  text-rendering: optimizeSpeed;
}

:where(img, svg, video, canvas, audio, iframe, embed, object) {
  display: block;
}
:where(img, svg, video) {
  block-size: auto;
  max-inline-size: 100%;
}

:where(svg) {
  fill: currentColor;
  stroke: none;
}

:where(svg):where(:not([fill])) {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke: currentColor;
}

:where(svg):where(:not([width])) {
  inline-size: 5rem;
}

:where(input, button, textarea, select),
:where(input[type="file"])::-webkit-file-upload-button {
  color: inherit;
  font-size: inherit;
  font: inherit;
  letter-spacing: inherit;
  word-spacing: inherit;
}

:where(textarea) {
  resize: block;
}

:where(p, h1, h2, h3, h4, h5, h6) {
  overflow-wrap: break-word;
}

:where(ul, ol) {
  list-style-position: inside;
}

:where(ul, ol, [role="list"]) {
  list-style: none;
}

:where(ul, ol, [role="list"]) li::before {
  border: 0px;
  clip: rect(0px, 0px, 0px, 0px);
  content: "\\200B";
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0px;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

a:not([class]) {
  text-decoration-skip-ink: auto;
}

:where(a[href], area, button, input, label[for], select, summary, textarea, [tabindex]:not([tabindex*="-"])) {
  cursor: pointer;
  touch-action: manipulation;
}
:where(input[type="file"]) {
  cursor: auto;
}
:where(input[type="file"])::-webkit-file-upload-button,
:where(input[type="file"])::file-selector-button {
  cursor: pointer;
}

@media (prefers-reduced-motion: no-preference) {
  :focus-visible {
    transition: outline-offset 145ms cubic-bezier(0.25, 0, 0.4, 1);
  }
  :where(:not(:active)):focus-visible {
    transition-duration: 0.25s;
  }
}
:where(:not(:active)):focus-visible {
  outline-offset: 5px;
}

:where(button, button[type], input[type="button"], input[type="submit"], input[type="reset"]),
:where(input[type="file"])::-webkit-file-upload-button,
:where(input[type="file"])::file-selector-button {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  text-align: center;
  user-select: none;
}

:where(button, button[type], input[type="button"], input[type="submit"], input[type="reset"])[disabled] {
  cursor: not-allowed;
}

/**********
*** UTILITIES
**********/
.content-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-base-2x);
  align-items: start;
  padding-block: var(--space-base-8x);
}

.col-span {
  grid-area: desc;
}

              
            
!

JS

              
                
              
            
!
999px

Console