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

              
                <!--
  This is a demo of how to use Font Awesome icons via CSS pseudo-elements alongside our SVG + JS framework.

  1. We're calling all styles for Font Awesome via our CDN. See the external references in the CSS configuration section of this demo.

  2.The general layout and decorative styling are being handled by the CSS included in the "demo styling" portion of this pen's CSS - anything that starts with "demo-*" is demo styling and not needed for core functionality of the demo to work.

  3. Read more about the techniques in this demo at https://fontawesome.com/docs/web/add-icons/pseudo-elements#css-pseudo-elements-with-our-svg-js-framework
  -->

<html>
  <head>
    <title>Using Font Awesome Icons Via CSS Pseudo-elements (SVG + JS)</title>
     
    <!-- SVG + JS reference with data-search-pseudo-elements set. https://fontawesome.com/docs/web/add-icons/pseudo-elements#css-pseudo-elements-with-our-svg-js-framework for more info -->
  </head>
  <script data-search-pseudo-elements src="https://kit.fontawesome.com/f737751420.js" crossorigin="anonymous"></script>

  <body>
    <main class="demo-frame" style="font-size: 2rem;">
      <section class="demo-example">
        <ul class="demo-icon-list">
          <li class="demo-icon">
            <span class="icon icon-solid icon-award">Solid Award</span>
          </li>
          <li class="demo-icon">
            <span class="icon icon-regular icon-award">Regular Award</span>
          </li>
          <li class="demo-icon">
            <span class="icon icon-light icon-award">Light Award</span>
          </li>
          
          <li class="demo-icon">
            <span class="icon icon-duotone icon-award">Duotone Award</span>
          </li>
          <li class="demo-icon">
            <span class="icon icon-brands icon-figma">Brand Icon</span>
          </li>
        </ul>
      </section>
    </main>
  </body>
</html>
              
            
!

CSS

              
                /* CSS pseudo-element styling */

/* general reset/setup styling for icons - needed on all */
.icon::before {
  display: none;  /* See https://fontawesome.com/docs/web/add-icons/pseudo-elements#css-pseudo-elements-with-our-svg-js-framework */
}

/* defining the right unicode values for each icon */
.icon-award::before {
  content: "\f559";
}

.icon-figma::before {
  content: "\f799";
}

.icon-solid::before {
  font: var(--fa-font-solid);
}

.icon-regular::before {
  font: var(--fa-font-regular);
}

.icon-light::before {
  font: var(--fa-font-light);
}

.icon-duotone::before {
  font: var(--fa-font-duotone);
}

.icon-brands::before {
  font: var(--fa-font-brands);
}

/* demo styling */
* {
  /* resetting the box model for all elements */
  box-sizing: border-box;
}

.demo-frame {
  /* making a nice frame/layout for examples */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: -1rem;
  padding: 3rem;
  min-height: 100vh;
  color: rgb(52, 58, 64);
}

.demo-example {
  /* individual demo example styling */
  margin-bottom: 1rem;
}

.demo-icon-list {
  list-style: none;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
}

.demo-icon {
  margin: 0;
  padding: 1.5rem 1rem;
}

.svg-inline--fa {
  margin-right: 0.5rem;
}
              
            
!

JS

              
                
              
            
!
999px

Console