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

              
                <body id="page" class="show-variable-fonts">
  <div class="wrapper">
			<div class="support support--vf">
        <span class="status-info__vf">The <strong>Variable Font</strong> is displayed.</span>
        <span class="status-info__fallback">The <strong>fallback fonts</strong> are shown.</span>
        <a id="toggle" class="switch switch-variable-off" onclick="toggleFonts()">Switch to </a>
			</div>
			<div class="support support--static">
				<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/814870/icon-cross.svg" class="icon"> The <strong>static fallback fonts</strong> are displayed, because your browser does not support variable fonts.
			</div>

    
			<main>
				<h1>A Variable Font implemented with fallback fonts</h1>
				<p><strong>Resize the browser window</strong> and see how the typeface on this page changes. On narrow screens the text is condensed to fit more words into one line, on bigger screens the body text gets wider. The heading is always at least slightly condensed to make a more compact appearance. This is done by only using <strong>one single font file.</strong></p>
          
          <p>How does it work? This page is set in the beautiful typeface Venn by Dalton Maag. It’s a variable font that can fluidly change its weight and width. If the browser does not support variable fonts, the <strong>fallback web fonts</strong> of Venn will be shown in Regular and Bold and there will be no condensed text. Toggle between the variable font and the fallback fonts to see the differences.</p>
        
        <p><strong>If you want to find out more about this</strong> read my article <a href="https://www.zeichenschatz.net/typografie/implementing-a-variable-font-with-fallback-web-fonts.html" target="_blank">Implementing a variable font with fallback web fonts</a>. It will give you step by step instructions and explain all the details.</p>
			</main>
		</div>

		<footer class="wrapper footer">
			Variable Font Demo by <a href="http://zeichenschatz.net" target="_blank">Oliver Schöndorfer</a>, Typeface: <a href="https://daltonmaag.com/library/venn" target="_blank">Venn by Dalton Maag</a>
		</footer>
</body>
              
            
!

CSS

              
                /* ###############
### LOAD FONTS ###
################## */

/* Load the variable font */
@font-face {
	font-family: 'Venn VF';
	src: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/814870/Venn_VF.woff2') format('woff2-variations'), /* for Safari */
			 url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/814870/Venn_VF.woff2') format('woff2'); /* for all other supporting browsers */
	font-display: fallback;
	font-weight: 300 800; /* prevents faux bolding in Safari */
	font-stretch: 75 125;
}

/* Load the static fonts as a fallback */
@font-face {
	font-family: 'Venn';
	src: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/814870/Venn_Regular.woff2') format('woff2');
	font-display: fallback; /* has nothing to do with the fact that this is the fallback font */
}

@font-face {
	font-family: 'Venn';
	src: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/814870/Venn_Bold.woff2') format('woff2');
	font-display: fallback; /* has nothing to do with the fact that this is the fallback font */
	font-weight: 700;
}





/* ########################
### TYPOGRAPHIC STYLING ###
########################### */

body {
	font-family: 'Venn', sans-serif;
	color: #222;
	margin: 0 1rem 2.4rem;
}

@supports (font-variation-settings: normal) {
	body {
		font-family: 'Venn VF', sans-serif;
	}
}

.wrapper {
	max-width: 50rem;
	margin: 0 auto;
}



/* ### Mobile first styling for narrow screens ### */

h1 {
	color: #37187c;
	margin: 0 0 0.5em;
	font-size: 1.8rem;
	line-height: 1.1;
  font-variation-settings: "wdth" 75, "wght" 700; /* older browsers will just ignore this */
  font-weight: 700; /* to prevent faux bolding of variable font */
}

p {
	font-size: 1.1rem;
  line-height: 1.5;
  font-variation-settings: "wdth" 88; /* older browsers will just ignore this */
}

strong {
  font-variation-settings: "wdth" 88, "wght" 700;
	font-weight: 700; /* to prevent faux bolding of variable font */
}





/* ### Big smart phone ### */

@media screen and (min-width: 460px) and (max-width: 699px) {
  h1 {
    font-variation-settings: "wdth" 85;
  }
	p {
    line-height: 1.6;
    font-variation-settings: "wdth" 95;
  }
  strong {
    font-variation-settings: "wdth" 95, "wght" 700;
  }
}


/* ### Tablet and above ### */

@media screen and (min-width: 700px) {

	h1 {
		font-size: 2.5rem;
    font-variation-settings: "wdth" 90;
	}
	p {
		font-size: 1.2rem;
		line-height: 1.7;
    font-variation-settings: "wdth" 100;
	}
  strong {
    font-variation-settings: "wdth" 100, "wght" 700;
  }

}





/*
#################################################################
Everything below this is only styling for the info box and toggle
#################################################################
*/ 



/* #################
### SUPPORT INFO ###
#################### */

.support {
  min-width: 14rem;
	color: #fff;
	padding: 1rem;
	text-align: left;
	margin: 0 0 2rem;
	border-radius: 5px;
	border-top-left-radius: 0;
	border-top-right-radius: 0;
	box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: all 0.2s ease-out;
}

.icon {
	width: 1.5rem;
	margin-bottom: -0.3rem;
}

.support--vf {
	display: none;
	background: #339949;
}

.support--static {
	display: inline-block;
	background: #E0011B;
}

@supports (font-variation-settings: normal) {
	.support--vf {
		display: inline-block;
	}
	.support--static {
		display: none;
	}
}

.show-fallback-fonts .status-info__vf {
  display: none;
}

.show-fallback-fonts .support--vf {
	background: #E0011B;
}

.show-variable-fonts .status-info__fallback {
  display: none;
}



/* ###########
### FOOTER ###
############## */

.footer {
	margin-top: 6rem;
	font-size: 0.8rem;
	color: #555;
}
.footer a:link,
.footer a:visited {
	color: inherit;
	transition: 0.3s ease-out all;
	text-decoration-skip: ink;
}
.footer a:hover,
.footer a:active {
	color: #9f5440;
	text-decoration: none;
}


@supports (font-variation-settings: normal) {
	.show-fallback-fonts {
		font-family: 'Venn', sans-serif;
	}
}

.switch {
  display: block;
  cursor: pointer;
  text-decoration: underline;
}
.switch:hover{
  color: inherit;
}
.switch:active{
	text-decoration: none;
}
.switch-variable-off:after {
  content: "fallback fonts";
}
.switch-variable-on:after {
  content: "variable font";
}



/* ##########
### LINKS ###
############# */

a:link,
a:visited {
	color: #37187c;
	text-decoration-skip: ink;
  transition: all 0.2s ease-out;
}

a:hover,
a:focus,
a:active {
  color: #9f5440;
  text-decoration: none;
}
              
            
!

JS

              
                function toggleFonts() {
  var myPageClasses = document.getElementById("page").classList;
  if (myPageClasses.contains("show-fallback-fonts")) {
    myPageClasses.remove("show-fallback-fonts");
  } else {
    myPageClasses.add("show-fallback-fonts");
  }
  if (myPageClasses.contains("show-variable-fonts")) {
    myPageClasses.remove("show-variable-fonts");
  } else {
    myPageClasses.add("show-variable-fonts");
  }

  var mySwitchClasses = document.getElementById("toggle").classList;
  if (mySwitchClasses.contains("switch-variable-on")) {
    mySwitchClasses.remove("switch-variable-on");
  } else {
    mySwitchClasses.add("switch-variable-on");
  }
  if (mySwitchClasses.contains("switch-variable-off")) {
    mySwitchClasses.remove("switch-variable-off");
  } else {
    mySwitchClasses.add("switch-variable-off");
  }
}
              
            
!
999px

Console