css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <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>
            
          
!
            
              /* ###############
### 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;
}
            
          
!
            
              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
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console