HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URL's 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 it's URL and the proper URL extention.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<h1>Canva Button styling with SVG icons</h1>
<p>SVG are inlined as an example, they can be served in any convenient way. CSS class names are just an example too.</p>
<table>
<tr>
<th></th>
<th>Large size</th>
<th>Default (normal) size</th>
<th>Small size</th>
<th>Tiny size</th>
</tr>
<tr>
<th>Default theme</th>
<td>
<span class="canva-btn canva-btn-theme-default canva-btn-size-l">
<span class="canva-btn-i"></span>
Design with Canva
</span>
</td>
<td>
<span class="canva-btn canva-btn-theme-default canva-btn-size-m">
<span class="canva-btn-i"></span>
Design with Canva
</span>
</td>
<td>
<span class="canva-btn canva-btn-theme-default canva-btn-size-s">
<span class="canva-btn-i"></span>
Design with Canva
</span>
</td>
<td>
<span class="canva-btn canva-btn-theme-default canva-btn-size-xs">
<span class="canva-btn-i"></span>
Design with Canva
</span>
</td>
</tr>
<tr>
<th>Dark theme</th>
<td>
<span class="canva-btn canva-btn-theme-dark canva-btn-size-l">
<span class="canva-btn-i"></span>
Design with Canva
</span>
</td>
<td>
<span class="canva-btn canva-btn-theme-dark canva-btn-size-m">
<span class="canva-btn-i"></span>
Design with Canva
</span>
</td>
<td>
<span class="canva-btn canva-btn-theme-dark canva-btn-size-s">
<span class="canva-btn-i"></span>
Design with Canva
</span>
</td>
<td>
<span class="canva-btn canva-btn-theme-dark canva-btn-size-xs">
<span class="canva-btn-i"></span>
Design with Canva
</span>
</td>
</tr>
</tr>
<tr>
<th>Light theme</th>
<td>
<span class="canva-btn canva-btn-theme-light canva-btn-size-l">
<span class="canva-btn-i"></span>
Design with Canva
</span>
</td>
<td>
<span class="canva-btn canva-btn-theme-light canva-btn-size-m">
<span class="canva-btn-i"></span>
Design with Canva
</span>
</td>
<td>
<span class="canva-btn canva-btn-theme-light canva-btn-size-s">
<span class="canva-btn-i"></span>
Design with Canva
</span>
</td>
<td>
<span class="canva-btn canva-btn-theme-light canva-btn-size-xs">
<span class="canva-btn-i"></span>
Design with Canva
</span>
</td>
</tr>
</table>
.canva-btn {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-smooth: always;
font-family: 'Open Sans', sans-serif;
font-weight: 600;
line-height: 1.6;
box-sizing: border-box;
user-select: none;
cursor: pointer;
border: 1px solid transparent;
max-width: 100%;
min-width: 80px;
display: inline-flex;
justify-content: center;
align-items: center;
white-space: nowrap;
transition: background-color 0.1s linear;
}
.canva-btn-i {
background-size: contain;
}
.canva-btn-theme-default {
background-color: #7D2AE8;
color: #ffffff;
}
.canva-btn-theme-default:hover,
.canva-btn-theme-default:focus {
background-color: #8D39FA;
}
.canva-btn-theme-default:active {
background-color: #6718CF;
}
.canva-btn-theme-dark {
background-color: #0E1318;
color: #ffffff;
}
.canva-btn-theme-dark:hover,
.canva-btn-theme-dark:focus {
background-color: #565A5D;
}
.canva-btn-theme-dark:active {
background-color: #707477;
}
.canva-btn-theme-light {
border-color: #9A9DA3;
background-color: #ffffff;
color: #0e1318;
}
.canva-btn-theme-light:hover,
.canva-btn-theme-light:focus {
background-color: #F3F3F3;
}
.canva-btn-theme-light:active {
background-color: #E7E7E8;
}
.canva-btn-size-l {
height: 48px;
border-radius: 5px;
font-size: 16px;
padding-right: 16px;
}
.canva-btn-size-l .canva-btn-i {
width: 32px;
height: 32px;
margin-left: 11px;
margin-right: 13px;
}
.canva-btn-size-m {
height: 40px;
border-radius: 4px;
font-size: 14px;
padding-right: 16px;
}
.canva-btn-size-m .canva-btn-i {
width: 24px;
height: 24px;
margin: 0 9px;
}
.canva-btn-size-s {
height: 32px;
border-radius: 3px;
font-size: 12px;
padding-right: 12px;
}
.canva-btn-size-s .canva-btn-i {
width: 20px;
height: 20px;
margin: 0 8px;
}
.canva-btn-size-xs {
height: 24px;
border-radius: 2px;
font-size: 12px;
padding-right: 8px;
}
.canva-btn-size-xs .canva-btn-i {
width: 16px;
height: 16px;
margin-left: 6px;
margin-right: 5px;
}
/* SVG files are inlined here just as an example. If you're going to use Canva logo in SVG format on your website, you can host SVG files and use them in CSS using URL in `background-image: url(...)`; */
.canva-btn-theme-default .canva-btn-i {
filter: drop-shadow(3px 3px 4px rgba(0, 0, 0, 0.1));
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='12' cy='12' r='12' fill='%235A32FA'/%3e%3ccircle cx='12' cy='12' r='12' fill='url(%23paint0_radial)'/%3e%3ccircle cx='12' cy='12' r='12' fill='url(%23paint1_radial)'/%3e%3ccircle cx='12' cy='12' r='12' fill='url(%23paint2_radial)'/%3e%3ccircle cx='12' cy='12' r='12' fill='url(%23paint3_radial)'/%3e%3cpath d='M17.1807 14.4617C17.0816 14.4617 16.9945 14.5452 16.9038 14.7279C15.8797 16.8047 14.1108 18.2741 12.0637 18.2741C9.69682 18.2741 8.23108 16.1375 8.23108 13.1857C8.23108 8.18574 11.0169 5.29483 13.4638 5.29483C14.6073 5.29483 15.3056 6.01338 15.3056 7.15685C15.3056 8.51398 14.5345 9.23252 14.5345 9.71116C14.5345 9.92601 14.6682 10.0561 14.9332 10.0561C15.9979 10.0561 17.2476 8.83267 17.2476 7.10433C17.2476 5.42851 15.789 4.19672 13.3421 4.19672C9.29816 4.19672 5.70422 7.94582 5.70422 13.1332C5.70422 17.1485 7.99713 19.8019 11.535 19.8019C15.29 19.8019 17.4612 16.0659 17.4612 14.8532C17.4612 14.5846 17.3239 14.4617 17.1807 14.4617Z' fill='white'/%3e%3cdefs%3e%3cradialGradient id='paint0_radial' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(4.63579 21.2716) rotate(-49.4156) scale(18.5619)'%3e%3cstop stop-color='%235A32FA'/%3e%3cstop offset='1' stop-color='%235A32FA' stop-opacity='0'/%3e%3c/radialGradient%3e%3cradialGradient id='paint1_radial' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(6.35368 2.72842) rotate(54.7035) scale(20.9321)'%3e%3cstop stop-color='%2300C4CC'/%3e%3cstop offset='1' stop-color='%2300C4CC' stop-opacity='0'/%3e%3c/radialGradient%3e%3cradialGradient id='paint2_radial' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(4.63579 21.2716) rotate(-45.1954) scale(18.3372 8.43355)'%3e%3cstop stop-color='%235A32FA'/%3e%3cstop offset='1' stop-color='%235A32FA' stop-opacity='0'/%3e%3c/radialGradient%3e%3cradialGradient id='paint3_radial' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(7 3) rotate(62.4472) scale(25.9422 43.459)'%3e%3cstop stop-color='%2300C4CC' stop-opacity='0.725916'/%3e%3cstop offset='0.0001' stop-color='%2300C4CC'/%3e%3cstop offset='1' stop-color='%2300C4CC' stop-opacity='0'/%3e%3c/radialGradient%3e%3c/defs%3e%3c/svg%3e ");
}
.canva-btn-theme-dark .canva-btn-i,
.canva-btn-theme-light .canva-btn-i {
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg width='1900' height='1900' viewBox='0 0 1900 1900' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='950' cy='950' r='950' fill='%237D2AE7'/%3e%3ccircle cx='950' cy='950' r='950' fill='url(%23paint0_radial)'/%3e%3ccircle cx='950' cy='950' r='950' fill='url(%23paint1_radial)'/%3e%3ccircle cx='950' cy='950' r='950' fill='url(%23paint2_radial)'/%3e%3ccircle cx='950' cy='950' r='950' fill='url(%23paint3_radial)'/%3e%3cpath d='M1360.14 1144.88C1352.3 1144.88 1345.4 1151.5 1338.22 1165.96C1257.14 1330.37 1117.1 1446.7 955.046 1446.7C767.666 1446.7 651.627 1277.55 651.627 1043.87C651.627 648.036 872.175 419.173 1065.89 419.173C1156.41 419.173 1211.69 476.058 1211.69 566.583C1211.69 674.022 1150.65 730.907 1150.65 768.799C1150.65 785.808 1161.23 796.107 1182.21 796.107C1266.5 796.107 1365.43 699.252 1365.43 562.425C1365.43 429.756 1249.96 332.239 1056.25 332.239C736.105 332.239 451.585 629.043 451.585 1039.71C451.585 1357.59 633.107 1567.65 913.186 1567.65C1210.46 1567.65 1382.35 1271.88 1382.35 1175.88C1382.35 1154.62 1371.48 1144.88 1360.14 1144.88Z' fill='white'/%3e%3cdefs%3e%3cradialGradient id='paint0_radial' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(367 1684) rotate(-49.4156) scale(1469.49)'%3e%3cstop stop-color='%236420FF'/%3e%3cstop offset='1' stop-color='%236420FF' stop-opacity='0'/%3e%3c/radialGradient%3e%3cradialGradient id='paint1_radial' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(503 216) rotate(54.7035) scale(1657.12)'%3e%3cstop stop-color='%2300C4CC'/%3e%3cstop offset='1' stop-color='%2300C4CC' stop-opacity='0'/%3e%3c/radialGradient%3e%3cradialGradient id='paint2_radial' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(367 1684) rotate(-45.1954) scale(1451.7 667.656)'%3e%3cstop stop-color='%236420FF'/%3e%3cstop offset='1' stop-color='%236420FF' stop-opacity='0'/%3e%3c/radialGradient%3e%3cradialGradient id='paint3_radial' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(777 256) rotate(66.5198) scale(1495.86 2505.9)'%3e%3cstop stop-color='%2300C4CC' stop-opacity='0.725916'/%3e%3cstop offset='0.0001' stop-color='%2300C4CC'/%3e%3cstop offset='1' stop-color='%2300C4CC' stop-opacity='0'/%3e%3c/radialGradient%3e%3c/defs%3e%3c/svg%3e");
}
.canva-btn-theme-dark:hover .canva-btn-i,
.canva-btn-theme-dark:focus .canva-btn-i,
.canva-btn-theme-light:hover .canva-btn-i,
.canva-btn-theme-light:focus .canva-btn-i {
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg width='1900' height='1900' viewBox='0 0 1900 1900' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='950' cy='950' r='950' fill='%237D2AE7'/%3e%3ccircle cx='950' cy='950' r='950' fill='url(%23paint0_radial)'/%3e%3ccircle cx='950' cy='950' r='950' fill='url(%23paint1_radial)'/%3e%3ccircle cx='950' cy='950' r='950' fill='url(%23paint2_radial)'/%3e%3ccircle cx='950' cy='950' r='950' fill='url(%23paint3_radial)'/%3e%3cpath d='M1360.14 1144.88C1352.3 1144.88 1345.4 1151.5 1338.22 1165.96C1257.14 1330.37 1117.1 1446.7 955.046 1446.7C767.666 1446.7 651.627 1277.55 651.627 1043.87C651.627 648.036 872.175 419.173 1065.89 419.173C1156.41 419.173 1211.69 476.058 1211.69 566.583C1211.69 674.022 1150.65 730.907 1150.65 768.799C1150.65 785.808 1161.23 796.107 1182.21 796.107C1266.5 796.107 1365.43 699.252 1365.43 562.425C1365.43 429.756 1249.96 332.239 1056.25 332.239C736.105 332.239 451.585 629.043 451.585 1039.71C451.585 1357.59 633.107 1567.65 913.186 1567.65C1210.46 1567.65 1382.35 1271.88 1382.35 1175.88C1382.35 1154.62 1371.48 1144.88 1360.14 1144.88Z' fill='white'/%3e%3cdefs%3e%3cradialGradient id='paint0_radial' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(367 1684) rotate(-49.4156) scale(1469.49)'%3e%3cstop stop-color='%236420FF'/%3e%3cstop offset='1' stop-color='%236420FF' stop-opacity='0'/%3e%3c/radialGradient%3e%3cradialGradient id='paint1_radial' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(503 216) rotate(54.7035) scale(1657.12)'%3e%3cstop stop-color='%2300C4CC'/%3e%3cstop offset='1' stop-color='%2300C4CC' stop-opacity='0'/%3e%3c/radialGradient%3e%3cradialGradient id='paint2_radial' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(367 1684) rotate(-45.1954) scale(1451.7 667.656)'%3e%3cstop stop-color='%236420FF'/%3e%3cstop offset='1' stop-color='%236420FF' stop-opacity='0'/%3e%3c/radialGradient%3e%3cradialGradient id='paint3_radial' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(777 256) rotate(66.5198) scale(1495.86 2505.9)'%3e%3cstop stop-color='%2300C4CC' stop-opacity='0.725916'/%3e%3cstop offset='0.0001' stop-color='%2300C4CC'/%3e%3cstop offset='1' stop-color='%2300C4CC' stop-opacity='0'/%3e%3c/radialGradient%3e%3c/defs%3e%3c/svg%3e");
}
.canva-btn-theme-dark:active .canva-btn-i,
.canva-btn-theme-light:active .canva-btn-i {
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg width='1900' height='1900' viewBox='0 0 1900 1900' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='950' cy='950' r='950' fill='%237D2AE7'/%3e%3ccircle cx='950' cy='950' r='950' fill='url(%23paint0_radial)'/%3e%3ccircle cx='950' cy='950' r='950' fill='url(%23paint1_radial)'/%3e%3ccircle cx='950' cy='950' r='950' fill='url(%23paint2_radial)'/%3e%3ccircle cx='950' cy='950' r='950' fill='url(%23paint3_radial)'/%3e%3cpath d='M1360.14 1144.88C1352.3 1144.88 1345.4 1151.5 1338.22 1165.96C1257.14 1330.37 1117.1 1446.7 955.046 1446.7C767.666 1446.7 651.627 1277.55 651.627 1043.87C651.627 648.036 872.175 419.173 1065.89 419.173C1156.41 419.173 1211.69 476.058 1211.69 566.583C1211.69 674.022 1150.65 730.907 1150.65 768.799C1150.65 785.808 1161.23 796.107 1182.21 796.107C1266.5 796.107 1365.43 699.252 1365.43 562.425C1365.43 429.756 1249.96 332.239 1056.25 332.239C736.105 332.239 451.585 629.043 451.585 1039.71C451.585 1357.59 633.107 1567.65 913.186 1567.65C1210.46 1567.65 1382.35 1271.88 1382.35 1175.88C1382.35 1154.62 1371.48 1144.88 1360.14 1144.88Z' fill='white'/%3e%3cdefs%3e%3cradialGradient id='paint0_radial' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(367 1684) rotate(-49.4156) scale(1469.49)'%3e%3cstop stop-color='%236420FF'/%3e%3cstop offset='1' stop-color='%236420FF' stop-opacity='0'/%3e%3c/radialGradient%3e%3cradialGradient id='paint1_radial' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(503 216) rotate(54.7035) scale(1657.12)'%3e%3cstop stop-color='%2300C4CC'/%3e%3cstop offset='1' stop-color='%2300C4CC' stop-opacity='0'/%3e%3c/radialGradient%3e%3cradialGradient id='paint2_radial' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(367 1684) rotate(-45.1954) scale(1451.7 667.656)'%3e%3cstop stop-color='%236420FF'/%3e%3cstop offset='1' stop-color='%236420FF' stop-opacity='0'/%3e%3c/radialGradient%3e%3cradialGradient id='paint3_radial' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='translate(777 256) rotate(66.5198) scale(1495.86 2505.9)'%3e%3cstop stop-color='%2300C4CC' stop-opacity='0.725916'/%3e%3cstop offset='0.0001' stop-color='%2300C4CC'/%3e%3cstop offset='1' stop-color='%2300C4CC' stop-opacity='0'/%3e%3c/radialGradient%3e%3c/defs%3e%3c/svg%3e");
}
Also see: Tab Triggers