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 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.
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 esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM 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.
<!-- image from here: https://s-media-cache-ak0.pinimg.com/736x/8d/fd/8d/8dfd8db5b0ff315865216a5099d324a2.jpg -->
<svg
xmlns="http://www.w3.org/2000/svg"
width="172.33589mm"
height="117.20642mm"
viewBox="0 0 610.63899 415.29836">
<g transform="translate(-53.319796,-359.27403)"><path
d="M 661.66039,747.46363 C 662.0677,686.27242 663.31602,623.78269 644.23378,564.88768 622.15502,508.4414 587.82981,455.80534 541.22286,417.03697 512.86875,403.3452 484.74625,386.31879 452.1975,386.36185 c -28.11599,-1.42388 -56.19205,1.76169 -84.26958,-1.33307 -47.21975,-6.25091 -71.82241,-10.02693 -81.16323,-15.51913 -26.41529,-15.19579 -56.88032,-6.97955 -64.81893,7.62928 0,0 -26.89494,26.17423 -45.90301,40.00801 -18.39168,9.26098 -35.89311,21.17625 -54.84035,28.78083 -28.229191,6.15886 -52.024261,30.4732 -55.180521,59.13001 -1.62041,35.58847 13.76948,48.18234 4.51297,66.92559 l -15.01088,34.46975 c 25.9396,18.18518 48.632601,26.49146 67.129111,22.02844 0,0 35.84323,-12.72065 39.17338,-26.15086 25.64628,-5.57813 47.39992,-13.67867 68.23782,-30.89125 9.25296,12.51037 13.14882,51.26898 27.62399,78.02832 13.00789,27.13934 18.53938,33.95544 34.76198,73.96482 -16.57236,8.27768 -50.70545,14.40175 -53.29562,29.81139 4.57023,3.1371 58.52526,10.88255 86.01215,-0.76232 28.67424,0.74644 26.46185,-37.17866 33.24362,-57.94491 5.09775,-32.86269 15.69265,-39.22087 12.03532,-72.41671 l -8.89196,-58.89431 9.87192,64.08275 c 37.40631,17.13231 80.66387,30.80831 120.86754,14.98955 21.07488,-1.52718 -2.32446,-9.96217 -8.34877,-15.73147 -1.45984,-0.68851 13.36034,9.79815 18.2595,13.47469 l 42.96768,31.32411 c 3.82223,31.57721 34.80824,46.1426 52.15185,69.01805 -13.95099,6.41336 -42.27956,7.96575 -36.35676,21.09832 -0.49592,13.35162 33.10512,11.33258 65.15472,10.01292 11.84632,-2.99797 23.69263,0.30268 35.53895,-24.03102 z" stroke="#000" stroke-width="3" fill="none" />
<path
d="m 128.00977,626.46125 c 0,0 -23.07857,33.8817 -27.39849,59.47377 -10.949181,18.58658 -39.752841,54.15434 -26.525941,55.22564 16.28786,6.44534 26.991301,-4.57443 43.279151,-28.32084 l 15.35712,-14.16042 c 65.2595,-10.60173 82.13895,-49.95579 112.82245,-81.59942" stroke="#000" stroke-width="2" fill="none"/>
<path
d="m 388.81898,635.13451 c -9.92765,22.49952 -13.58251,54.0165 -16.22968,83.90049 -10.42741,0.55994 -14.22055,0.41753 -20.94151,8.49626 -0.50548,4.89976 -6.23393,10.86335 -0.69806,16.63849 9.22832,6.87459 19.22215,6.91687 34.55352,9.91229 17.48664,3.92999 29.1915,1.99563 40.83596,-0.70802 6.8637,-6.26721 9.28395,-17.38653 6.28246,-23.71871 63.48885,-59.72264 45.20176,-67.16494 71.02667,-88.32562" stroke="#000" stroke-width="2" fill="none"/>
<path
d="m 78.186389,473.97123 c -5.41217,-9.67049 -4.53435,-21.06522 -0.69804,-29.82538 6.86537,-6.46218 17.61198,-4.31917 19.02187,-0.17701 0,0 1.47186,7.25663 0.52355,12.03635" stroke="#000" stroke-width="2" fill="none"/>
<path
d="m 133.51221,484.62424 c -1.71696,-5.82731 -3.68172,-11.41525 8.88473,-31.04009 6.34445,-7.96929 13.62981,-11.83211 21.47144,-13.26713 6.79783,2.34152 12.0199,8.33648 15.0547,16.77166 0.43723,1.47507 1.4456,10.10125 4.19557,12.01551 8.48413,11.24904 1.62669,19.71794 -4.19557,24.53168" stroke="#000" stroke-width="2" fill="none"/></g>
</svg>
body {
background: #ADD8E6;
color: white;
}
svg {
position: fixed;
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 50%;
max-width: 1000px;
max-height: 1000px;
color
}
.pointer {
cursor: pointer;
}
var drawBear = function() {
var paths = document.querySelectorAll('path');
for (var i = 0; i < paths.length; i++) {
var path = paths[i];
var length = path.getTotalLength();
// Clear any previous transition
path.style.transition = path.style.WebkitTransition =
'none';
// Set up the starting positions
path.style.strokeDasharray = length + ' ' + length;
path.style.strokeDashoffset = length;
// Trigger a layout so styles are calculated & the browser
// picks up the starting position before animating
path.getBoundingClientRect();
// Define our transition
path.style.transition = path.style.WebkitTransition =
'stroke-dashoffset 6s ease-in-out';
// Go!
path.style.strokeDashoffset = '0';
}
}
drawBear();
/* From Modernizr */
function whichTransitionEvent() {
var t;
var el = document.createElement('fakeelement');
var transitions = {
'transition': 'transitionend',
'OTransition': 'oTransitionEnd',
'MozTransition': 'transitionend',
'WebkitTransition': 'webkitTransitionEnd'
}
for (t in transitions) {
if (el.style[t] !== undefined) {
return transitions[t];
}
}
}
/* Listen for a transition! */
var transitionEvent = whichTransitionEvent();
var transitionDone = false;
transitionEvent && document.body.addEventListener(transitionEvent, function() {
transitionDone = true;
document.body.className = "pointer";
});
document.body.onclick = function() {
if (transitionDone) {
drawBear();
transitionDone = false;
document.body.className = "";
}
};
Also see: Tab Triggers