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.
<h1> Press the Keys Below:</h1>
<div class="notes">
<div data-key="65" class="key">
<svg version="1.1" id="capa" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 55 55" style="enable-background:new 0 0 55 55;" xml:space="preserve">
<path d="M52.66,0.249c-0.216-0.189-0.501-0.275-0.789-0.241l-31,4.011C20.373,4.084,20,4.507,20,5.01v6.017v4.212v25.384
C18.174,38.428,15.273,37,12,37c-5.514,0-10,4.037-10,9s4.486,9,10,9s10-4.037,10-9c0-0.232-0.019-0.46-0.039-0.687
C21.974,45.248,22,45.189,22,45.121V16.118l29-3.753v18.257C49.174,28.428,46.273,27,43,27c-5.514,0-10,4.037-10,9s4.486,9,10,9
c5.464,0,9.913-3.966,9.993-8.867c0-0.013,0.007-0.024,0.007-0.037V11.227V7.016V1C53,0.712,52.876,0.438,52.66,0.249z"/>
</svg>
<span>A</span>
</div>
<div data-key="83" class="key">
<svg version="1.1" id="capa_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 415.963 415.963" style="enable-background:new 0 0 415.963 415.963;" xml:space="preserve">
<path d="M328.712,264.539c12.928-21.632,21.504-48.992,23.168-76.064c1.056-17.376-2.816-35.616-11.2-52.768
c-13.152-26.944-35.744-42.08-57.568-56.704c-16.288-10.912-31.68-21.216-42.56-35.936l-1.952-2.624
c-6.432-8.64-13.696-18.432-14.848-26.656c-1.152-8.32-8.704-14.24-16.96-13.76c-8.384,0.576-14.88,7.52-14.88,15.936v285.12
c-13.408-8.128-29.92-13.12-48-13.12c-44.096,0-80,28.704-80,64s35.904,64,80,64s80-28.704,80-64V165.467
c24.032,9.184,63.36,32.576,74.176,87.2c-2.016,2.976-3.936,6.176-6.176,8.736c-5.856,6.624-5.216,16.736,1.44,22.56
c6.592,5.888,16.704,5.184,22.56-1.44c4.288-4.864,8.096-10.56,11.744-16.512C328.04,265.563,328.393,265.083,328.712,264.539z"/>
</svg>
<span>S</span>
</div>
<div data-key="68" class="key">
<svg version="1.1" id="capa" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 55 55" style="enable-background:new 0 0 55 55;" xml:space="preserve">
<path d="M52.66,0.249c-0.216-0.189-0.501-0.275-0.789-0.241l-31,4.011C20.373,4.084,20,4.507,20,5.01v6.017v4.212v25.384
C18.174,38.428,15.273,37,12,37c-5.514,0-10,4.037-10,9s4.486,9,10,9s10-4.037,10-9c0-0.232-0.019-0.46-0.039-0.687
C21.974,45.248,22,45.189,22,45.121V16.118l29-3.753v18.257C49.174,28.428,46.273,27,43,27c-5.514,0-10,4.037-10,9s4.486,9,10,9
c5.464,0,9.913-3.966,9.993-8.867c0-0.013,0.007-0.024,0.007-0.037V11.227V7.016V1C53,0.712,52.876,0.438,52.66,0.249z"/>
</svg>
<span>D</span>
</div>
<div data-key="70" class="key">
<svg version="1.1" id="capa_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 415.963 415.963" style="enable-background:new 0 0 415.963 415.963;" xml:space="preserve">
<path d="M328.712,264.539c12.928-21.632,21.504-48.992,23.168-76.064c1.056-17.376-2.816-35.616-11.2-52.768
c-13.152-26.944-35.744-42.08-57.568-56.704c-16.288-10.912-31.68-21.216-42.56-35.936l-1.952-2.624
c-6.432-8.64-13.696-18.432-14.848-26.656c-1.152-8.32-8.704-14.24-16.96-13.76c-8.384,0.576-14.88,7.52-14.88,15.936v285.12
c-13.408-8.128-29.92-13.12-48-13.12c-44.096,0-80,28.704-80,64s35.904,64,80,64s80-28.704,80-64V165.467
c24.032,9.184,63.36,32.576,74.176,87.2c-2.016,2.976-3.936,6.176-6.176,8.736c-5.856,6.624-5.216,16.736,1.44,22.56
c6.592,5.888,16.704,5.184,22.56-1.44c4.288-4.864,8.096-10.56,11.744-16.512C328.04,265.563,328.393,265.083,328.712,264.539z"/>
</svg>
<span>F</span>
</div>
<div data-key="71" class="key">
<svg version="1.1" id="capa" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 55 55" style="enable-background:new 0 0 55 55;" xml:space="preserve">
<path d="M52.66,0.249c-0.216-0.189-0.501-0.275-0.789-0.241l-31,4.011C20.373,4.084,20,4.507,20,5.01v6.017v4.212v25.384
C18.174,38.428,15.273,37,12,37c-5.514,0-10,4.037-10,9s4.486,9,10,9s10-4.037,10-9c0-0.232-0.019-0.46-0.039-0.687
C21.974,45.248,22,45.189,22,45.121V16.118l29-3.753v18.257C49.174,28.428,46.273,27,43,27c-5.514,0-10,4.037-10,9s4.486,9,10,9
c5.464,0,9.913-3.966,9.993-8.867c0-0.013,0.007-0.024,0.007-0.037V11.227V7.016V1C53,0.712,52.876,0.438,52.66,0.249z"/>
</svg>
<span>G</span>
</div>
<div data-key="72" class="key">
<svg version="1.1" id="capa_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 415.963 415.963" style="enable-background:new 0 0 415.963 415.963;" xml:space="preserve">
<path d="M328.712,264.539c12.928-21.632,21.504-48.992,23.168-76.064c1.056-17.376-2.816-35.616-11.2-52.768
c-13.152-26.944-35.744-42.08-57.568-56.704c-16.288-10.912-31.68-21.216-42.56-35.936l-1.952-2.624
c-6.432-8.64-13.696-18.432-14.848-26.656c-1.152-8.32-8.704-14.24-16.96-13.76c-8.384,0.576-14.88,7.52-14.88,15.936v285.12
c-13.408-8.128-29.92-13.12-48-13.12c-44.096,0-80,28.704-80,64s35.904,64,80,64s80-28.704,80-64V165.467
c24.032,9.184,63.36,32.576,74.176,87.2c-2.016,2.976-3.936,6.176-6.176,8.736c-5.856,6.624-5.216,16.736,1.44,22.56
c6.592,5.888,16.704,5.184,22.56-1.44c4.288-4.864,8.096-10.56,11.744-16.512C328.04,265.563,328.393,265.083,328.712,264.539z"/>
</svg>
<span>H</span>
</div>
</div>
<div data-key="32" class="secret">
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" viewBox="0 0 32 40.00000125" version="1.1" x="0px" y="0px"><g transform="translate(0,-1020.3621)"><path style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" d="M 4.75 3.0019531 A 0.50004997 0.50004997 0 0 0 4.2910156 3.3789062 L 4.2382812 3.5761719 L 4.0410156 3.5234375 A 0.50004997 0.50004997 0 0 0 3.8925781 3.5019531 L 3.8925781 3.5039062 A 0.50004997 0.50004997 0 0 0 3.78125 4.4882812 L 3.9785156 4.5410156 L 3.9257812 4.7402344 A 0.5005348 0.5005348 0 1 0 4.8925781 5 L 4.9453125 4.8007812 L 5.1445312 4.8535156 A 0.50004997 0.50004997 0 1 0 5.4023438 3.8886719 L 5.2050781 3.8359375 L 5.2578125 3.6367188 A 0.50004997 0.50004997 0 0 0 4.75 3.0019531 z M 19.939453 4.0214844 A 0.50005 0.50005 0 0 0 19.890625 4.0234375 A 0.50005 0.50005 0 0 0 19.453125 4.3632812 L 16.888672 11.615234 A 0.50005 0.50005 0 1 0 17.830078 11.947266 L 20.396484 4.6953125 A 0.50005 0.50005 0 0 0 19.939453 4.0214844 z M 10.955078 4.1875 A 0.50367182 0.50367254 0 0 0 10.451172 4.6914062 A 0.50367182 0.50367254 0 0 0 10.955078 5.1953125 A 0.50367182 0.50367254 0 0 0 11.458984 4.6914062 A 0.50367182 0.50367254 0 0 0 10.955078 4.1875 z M 25.058594 5.1953125 A 0.50367182 0.50367254 0 0 0 24.554688 5.6992188 A 0.50367182 0.50367254 0 0 0 25.058594 6.203125 A 0.50367182 0.50367254 0 0 0 25.5625 5.6992188 A 0.50367182 0.50367254 0 0 0 25.058594 5.1953125 z M 6.3710938 5.5507812 A 0.50005 0.50005 0 0 0 6.0214844 6.4101562 L 13.1875 13.576172 A 0.50005 0.50005 0 1 0 13.894531 12.869141 L 6.7285156 5.703125 A 0.50005 0.50005 0 0 0 6.3710938 5.5507812 z M 15.480469 5.6328125 A 0.50005 0.50005 0 0 0 14.988281 6.140625 L 14.988281 12.751953 A 0.50005 0.50005 0 1 0 15.988281 12.751953 L 15.988281 6.140625 A 0.50005 0.50005 0 0 0 15.480469 5.6328125 z M 11.888672 6.4355469 A 0.50005 0.50005 0 0 0 11.443359 7.140625 L 12.78125 10.246094 A 0.50005 0.50005 0 1 0 13.699219 9.8496094 L 12.363281 6.7441406 A 0.50005 0.50005 0 0 0 11.888672 6.4355469 z M 23.779297 6.5742188 A 0.50005 0.50005 0 0 0 23.433594 6.71875 L 19.650391 10.341797 A 0.50008438 0.50008438 0 0 0 20.341797 11.064453 L 24.125 7.4414062 A 0.50005 0.50005 0 0 0 23.779297 6.5742188 z M 28.492188 8.4316406 A 0.50005 0.50005 0 0 0 28.267578 8.4882812 L 18.671875 13.355469 A 0.50051399 0.50051399 0 0 0 19.125 14.248047 L 28.720703 9.3808594 A 0.50005 0.50005 0 0 0 28.492188 8.4316406 z M 3.4980469 9.8886719 A 0.50005 0.50005 0 0 0 3.3203125 10.855469 L 5.6679688 11.804688 L 8.0175781 12.751953 L 10.367188 13.701172 A 0.50031297 0.50031297 0 0 0 10.742188 12.773438 L 8.3925781 11.824219 L 6.0429688 10.876953 L 3.6933594 9.9277344 A 0.50005 0.50005 0 0 0 3.4980469 9.8886719 z M 14.480469 13.761719 A 0.50005 0.50005 0 0 0 14.132812 14.621094 L 14.78125 15.269531 L 14.132812 15.917969 A 0.50005 0.50005 0 1 0 14.839844 16.625 L 15.488281 15.976562 L 16.136719 16.625 A 0.50005 0.50005 0 1 0 16.84375 15.917969 L 16.195312 15.269531 L 16.84375 14.621094 A 0.50005 0.50005 0 0 0 16.480469 13.761719 A 0.50005 0.50005 0 0 0 16.136719 13.914062 L 15.488281 14.5625 L 14.839844 13.914062 A 0.50005 0.50005 0 0 0 14.480469 13.761719 z M 27.568359 13.849609 A 0.50004997 0.50004997 0 0 0 27.076172 14.355469 L 27.076172 14.560547 L 26.871094 14.560547 A 0.50004997 0.50004997 0 1 0 26.871094 15.560547 L 27.076172 15.560547 L 27.076172 15.765625 A 0.50004997 0.50004997 0 1 0 28.076172 15.765625 L 28.076172 15.560547 L 28.28125 15.560547 A 0.50004997 0.50004997 0 1 0 28.28125 14.560547 L 28.076172 14.560547 L 28.076172 14.355469 A 0.50004997 0.50004997 0 0 0 27.568359 13.849609 z M 6.421875 14.769531 A 0.50005 0.50005 0 1 0 6.421875 15.769531 L 12.970703 15.769531 A 0.50005 0.50005 0 1 0 12.970703 14.769531 L 6.421875 14.769531 z M 18.015625 14.769531 A 0.50005 0.50005 0 1 0 18.015625 15.769531 L 24.554688 15.769531 A 0.50005 0.50005 0 1 0 24.554688 14.769531 L 18.015625 14.769531 z M 11.373047 16.53125 A 0.50005 0.50005 0 0 0 11.195312 16.574219 L 7.8886719 17.998047 A 0.50005 0.50005 0 1 0 8.2851562 18.916016 L 11.589844 17.492188 A 0.50005 0.50005 0 0 0 11.373047 16.53125 z M 20.210938 16.636719 A 0.50005 0.50005 0 0 0 20.03125 17.601562 L 27.484375 20.611328 A 0.50035933 0.50035933 0 0 0 27.859375 19.683594 L 20.40625 16.675781 A 0.50005 0.50005 0 0 0 20.210938 16.636719 z M 17.630859 16.8125 A 0.50005 0.50005 0 0 0 17.283203 17.669922 L 24.449219 24.835938 A 0.50005 0.50005 0 1 0 25.15625 24.128906 L 17.990234 16.962891 A 0.50005 0.50005 0 0 0 17.630859 16.8125 z M 13.320312 17.021484 A 0.50005 0.50005 0 0 0 12.980469 17.179688 L 3.3867188 27.142578 A 0.50005413 0.50005413 0 0 0 4.1074219 27.835938 L 13.699219 17.873047 A 0.50005 0.50005 0 0 0 13.320312 17.021484 z M 15.480469 17.28125 A 0.50005 0.50005 0 0 0 14.988281 17.787109 L 14.988281 28.365234 A 0.50005 0.50005 0 1 0 15.988281 28.365234 L 15.988281 17.787109 A 0.50005 0.50005 0 0 0 15.480469 17.28125 z M 5.5722656 18.294922 A 0.50004997 0.50004997 0 0 0 5.1152344 18.671875 L 5.0625 18.871094 L 4.8632812 18.818359 A 0.50004997 0.50004997 0 0 0 4.7148438 18.798828 A 0.50004997 0.50004997 0 0 0 4.6054688 19.783203 L 4.8027344 19.835938 L 4.75 20.035156 A 0.50004997 0.50004997 0 1 0 5.7148438 20.292969 L 5.7675781 20.095703 L 5.9667969 20.148438 A 0.50004997 0.50004997 0 1 0 6.2246094 19.183594 L 6.0273438 19.130859 L 6.0800781 18.931641 A 0.50004997 0.50004997 0 0 0 5.6230469 18.294922 A 0.50004997 0.50004997 0 0 0 5.5722656 18.294922 z M 17.289062 18.974609 A 0.50005 0.50005 0 0 0 16.841797 19.679688 L 18.615234 23.794922 A 0.50005 0.50005 0 1 0 19.533203 23.398438 L 17.761719 19.283203 A 0.50005 0.50005 0 0 0 17.289062 18.974609 z M 13.625 19.597656 A 0.50005 0.50005 0 0 0 13.173828 19.917969 L 10.789062 25.822266 A 0.5003292 0.5003292 0 0 0 11.716797 26.197266 L 14.101562 20.291016 A 0.50005 0.50005 0 0 0 13.625 19.597656 z M 19.859375 24.15625 A 0.50004997 0.50004997 0 0 0 19.402344 24.533203 L 19.349609 24.730469 L 19.150391 24.677734 A 0.50004997 0.50004997 0 0 0 19.001953 24.65625 L 19.001953 24.658203 A 0.50004997 0.50004997 0 0 0 18.892578 25.642578 L 19.089844 25.695312 L 19.037109 25.894531 A 0.50004997 0.50004997 0 1 0 20.001953 26.154297 L 20.054688 25.955078 L 20.253906 26.007812 A 0.50004997 0.50004997 0 1 0 20.511719 25.042969 L 20.314453 24.990234 L 20.367188 24.791016 A 0.50004997 0.50004997 0 0 0 19.859375 24.15625 z M 10.416016 27.357422 A 0.50367182 0.50367254 0 0 0 9.9472656 27.861328 A 0.50367182 0.50367254 0 0 0 10.451172 28.363281 A 0.50367182 0.50367254 0 0 0 10.955078 27.861328 A 0.50367182 0.50367254 0 0 0 10.451172 27.357422 A 0.50367182 0.50367254 0 0 0 10.416016 27.357422 z " transform="translate(0,1020.3621)"/></g></svg>
</div>
* {
box-sizing: border-box;
}
body {
background: #f1f1f1;
font-family: 'Roboto', sans-serif;
}
h1 {
margin: 0;
padding: 10px;
}
.notes {
display: flex;
justify-content: center;
align-items: center;
width: calc(100vw - 20px);
height: calc(100vh - 56px);
}
.key {
display: flex;
flex-flow: column wrap;
justify-content: center;
align-items: center;
transition: all 300ms ease;
transform: scale(1);
span {
font-size: 24px;
display: block;
margin-top: 10px;
}
svg {
width: 60px;
height: 60px;
transform: scale(0);
}
&.active {
transform: scale(1.1);
svg {
transform: scale(1);
}
}
}
.secret {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
transition: all 300ms ease;
transform: scale(0);
svg {
width: 99vw;
height: 99vh;
}
&.active {
transform: scale(1);
}
}
function playNote(e) {
const key = document.querySelector(`.key[data-key="${e.keyCode}"]`);
if (!key) return;
key.classList.toggle('active');
}
function removeTransition(e) {
if (e.propertyName !== 'transform') return;
this.classList.remove('active');
}
const keys = document.querySelectorAll('.key');
keys.forEach(key => key.addEventListener('transitionend', removeTransition));
window.addEventListener('keydown', playNote);
// Secret stuff for bonfire night
function firework(e) {
const firewo = document.querySelector(`.secret[data-key="${e.keyCode}"]`);
if (!firewo) return;
firewo.classList.toggle('active');
}
const secrets = document.querySelectorAll('.secret');
secrets.forEach(key => key.addEventListener('transitionend', removeTransition));
window.addEventListener('keydown', firework);
Also see: Tab Triggers