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

              
                Tweet!<h1>Labelling buttons</h1>

<h2>Text only</h2>

<p>
  <button>Tweet!</button>
</p>

<h2>Text and Icon</h2>

<p>
  <button>
    <svg aria-hidden="true" width="28" height="28">
      <use xlink:href="#twitter"></use>
    </svg>
    Tweet!
  </button>
</p>

<h2>Icon-only using aria-label on the button</h2>
<p>
  <button aria-label="Tweet!">
  <svg aria-hidden="true" width="28" height="28">
    <use xlink:href="#twitter"></use>
  </svg>
</button>
</p>
  
<h2>Icon-only using aria-labelledby on the button</h2>

<h2 id="heading" role="presentation" style="font-size:1rem">Tweet!</h2>

<button aria-labelledby="heading">
  <svg aria-hidden="true" width="28" height="28">
    <use xlink:href="#twitter"></use>
  </svg>
</button>

<h2>Icon-only using title inside the svg</h2>

<button>
  <svg aria-labelledby="title_twitter_h72d" width="28" height="28">
    <title id="title_twitter_h72d">Tweet!</title>
    <use xlink:href="#twitter"></use>
  </svg>
</button>

<h2>Icon-only using a sr-only class</h2>

<button>
  <svg aria-hidden="true" width="28" height="28">
    <use xlink:href="#twitter"></use>
  </svg>
  <span class="sr-only">Tweet!</span>
</button>

<h2>Icon-only using alt</h2>

<button>
  <img src="https://assets.codepen.io/144736/twitter.png" alt="Tweet!" width="28" />
</button>

<h2>Icon-only using background-image</h2>

<button class="bg">
  <span class="sr-only">Tweet!</span>
</button>  

<div>
<svg>
    <symbol id="twitter" fill="currentcolor" viewBox="0 0 512 512">
      <path d="M512 97.248c-19.04 8.352-39.328 13.888-60.48 16.576 21.76-12.992 38.368-33.408 46.176-58.016-20.288 12.096-42.688 20.64-66.56 25.408C411.872 60.704 384.416 48 354.464 48c-58.112 0-104.896 47.168-104.896 104.992 0 8.32.704 16.32 2.432 23.936-87.264-4.256-164.48-46.08-216.352-109.792-9.056 15.712-14.368 33.696-14.368 53.056 0 36.352 18.72 68.576 46.624 87.232-16.864-.32-33.408-5.216-47.424-12.928v1.152c0 51.008 36.384 93.376 84.096 103.136-8.544 2.336-17.856 3.456-27.52 3.456-6.72 0-13.504-.384-19.872-1.792 13.6 41.568 52.192 72.128 98.08 73.12-35.712 27.936-81.056 44.768-130.144 44.768-8.608 0-16.864-.384-25.12-1.44C46.496 446.88 101.6 464 161.024 464c193.152 0 298.752-160 298.752-298.688 0-4.64-.16-9.12-.384-13.568 20.832-14.784 38.336-33.248 52.608-54.496z"></path>
    </symbol>
</svg> 
</div>
              
            
!

CSS

              
                .sr-only {
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  left: 0;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  top: 0;
  white-space: nowrap;
  width: 1px;
}

.bg {
    background: url(https://assets.codepen.io/144736/twitter.png);
    width: 3.57rem;
    height: 2.8rem;
    background-size: 56%;
    background-repeat: no-repeat;
    background-position: center;
}


body {
  margin: 0;
  padding: 0.8rem 10px;
  font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif; 
  max-width: 80ch;
  line-height: 1.6;
  font-size: 1.2rem;
  margin-left: auto;
  margin-right: auto;
}

button {
    border: 2px solid #153a51;
    background-color: #fff;
    font-family: inherit;
    font-size: 1.3rem;
    padding: 0.3em 0.6em;
    border-radius: 4px;
    font-weight: bold;
    display: flex;
    gap: 0.5rem;
  }

  button:where(:hover, :focus) {
    background-color: hsl(186, 56%, 48%);
    color: #fff;
  }
              
            
!

JS

              
                
              
            
!
999px

Console