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.
<div class="page">
<!--Sidebar-->
<div class="sidebar">
<div class="panel">
<div class="panel-header ">Project</div>
<!--Tree-->
<div class="panel-body">
<ul class="tree-group">
<li class="tree-item tree-item--chevron-down">
<span class="tree-item-label tree-item-label--repo">vintage-shop</span>
<ul class="tree-group">
<li class="tree-item tree-item--chevron-right">
<span class="tree-item-label tree-item-label--file-directory">git</span>
</li>
<li class="tree-item tree-item--chevron-right">
<span class="tree-item-label tree-item-label--file-directory">dist</span>
</li>
<li class="tree-item tree-item--chevron-right">
<span class="tree-item-label tree-item-label--file-directory">node_modules</span>
</li>
<li class="tree-item tree-item--chevron-right">
<span class="tree-item-label tree-item-label--file-directory">src</span>
</li>
<li class="tree-item">
<span class="tree-item-label tree-item-label--file-text">.editconfig</span>
</li>
<li class="tree-item">
<span class="tree-item-label tree-item-label--file-text">build.js</span>
</li>
<li class="tree-item">
<span class="tree-item-label tree-item-label--file-text">development.html</span>
</li>
<li class="tree-item">
<span class="tree-item-label tree-item-label--file-text">LICENSE</span>
</li>
<li class="tree-item">
<span class="tree-item-label tree-item-label--file-text">package-lock.json</span>
</li>
<li class="tree-item">
<span class="tree-item-label tree-item-label--file-text">production.html</span>
</li>
<li class="tree-item">
<span class="tree-item-label tree-item-label--file-book">README.md</span>
</li>
<li class="tree-item">
<span class="tree-item-label tree-item-label--file-text">test.html</span>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div><!--Sidebar ends-->
<div class="editor">
<!--Editor 1 -->
<div class="panel">
<div class="panel-header">
<div class="tabs">
<div class="tab-item">scafolding.less</div>
<div class="tab-item tab-item--selected">styles.less</div>
<div class="tab-item">cart-item.stash</div>
</div>
</div>
<div class="panel-body">
<ol class="editor-container">
<li class="editor-line"></li>
<li class="editor-line"><span class="editor-content">Hey there!</span></li>
<li class="editor-line"></li>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
enim tortor, interdum eu consequat ac, ullamcorper ac lacus. Morbi
sagittis diam a dui rhoncus, eget egestas augue tempor. Ut vitae
ornare ex. Morbi malesuada, felis non molestie sollicitudin, arcu
lorem blandit velit, non ultrices dolor quam quis metus. Nunc ut nisi
eget dolor imperdiet gravida. Donec dapibus volutpat leo. Nullam
suscipit efficitur nibh, pretium laoreet ante malesuada eu. Nam vitae
bibendum ante. Ut vitae dolor eget nibh sagittis imperdiet at at
lacus. Curabitur elementum luctus velit. Curabitur non molestie neque,
at venenatis enim. Praesent imperdiet non risus nec sagittis.
Phasellus interdum consequat volutpat. Vestibulum ante ipsum primis in
faucibus orci luctus et ultrices posuere cubilia curae; Aenean cursus
mauris est, at maximus turpis sollicitudin ut. Aliquam pretium velit
enim, ut bibendum mi posuere a.
</p>
<p>
Aliquam erat volutpat. Morbi justo mauris, viverra eu nibh in, rhoncus
gravida quam. Fusce quis faucibus nisl, vel ultrices enim. Integer
ornare at turpis nec feugiat. Aliquam erat volutpat. Curabitur
fringilla varius velit ut vestibulum. Fusce finibus, metus nec congue
pretium, massa erat efficitur nisl, quis faucibus erat mi sed tortor.
Sed tincidunt neque sit amet aliquam pulvinar. Integer urna turpis,
elementum ac tempor et, viverra eget justo. Mauris sed quam id enim
euismod luctus.
</p>
<p>
Nunc aliquam eros sem, id faucibus nisi tincidunt ut. Nam a lorem
rhoncus, pulvinar arcu finibus, placerat arcu. Cras vestibulum cursus
metus at fringilla. Suspendisse potenti. Nam magna mauris, ultricies
at fringilla et, porta vel leo. Nam sit amet congue velit. Nullam
vitae ligula ante. Proin sollicitudin tellus nec enim dictum, ac
dictum orci malesuada. Praesent arcu nunc, volutpat vel tempor eu,
pulvinar condimentum nisl.
</p>
<p>
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices
posuere cubilia curae; Phasellus feugiat vehicula ligula, vitae dictum
neque. Quisque purus ante, rutrum a rutrum non, ullamcorper ut lorem.
Mauris auctor mauris a justo imperdiet, laoreet placerat mi hendrerit.
Ut elementum, elit in feugiat facilisis, massa quam accumsan neque,
aliquet maximus turpis justo eget quam. Nunc egestas sodales
fringilla. Vestibulum placerat consectetur elementum.
</p>
<p>
Phasellus tincidunt aliquet ipsum, ac semper mi viverra ultrices.
Donec lacus turpis, maximus quis eleifend a, volutpat ut ante. Nulla
sed libero nec purus luctus efficitur. Nullam hendrerit elit ut augue
blandit ullamcorper. Vestibulum ante ipsum primis in faucibus orci
luctus et ultrices posuere cubilia curae; Integer posuere ac elit et
pretium. Vivamus eleifend risus quis diam pharetra, et ultrices turpis
volutpat. Curabitur id aliquet nulla, eu commodo diam.
</p>
<p>
Vestibulum facilisis massa vehicula, mollis urna sit amet, ullamcorper
est. Mauris egestas dui vel consectetur vehicula. Aliquam erat
volutpat. Sed velit ante, tincidunt vel lobortis a, bibendum at magna.
Curabitur euismod non lorem sit amet porttitor. Praesent dignissim
tellus nec laoreet tempus. Curabitur congue blandit nisl, in lobortis
ligula ullamcorper eu. Donec tincidunt, nunc in condimentum dictum,
leo velit egestas dui, sit amet tempor lectus odio quis massa. Morbi
ac ex malesuada, gravida magna ac, vulputate arcu. Sed laoreet mattis
urna vitae molestie. Vestibulum in velit sed augue rhoncus ultrices.
</p>
<p>
Proin tempus libero at convallis vulputate. Mauris eu eros lacus. Cras
libero ipsum, posuere non ante eget, dignissim rutrum velit. Curabitur
ultrices magna eget orci volutpat, in porta dolor laoreet. Quisque
ullamcorper consequat pellentesque. Aenean facilisis eget nisi sed
lobortis. Suspendisse id tincidunt magna. Aenean facilisis nisi ex,
non tempus nulla tristique et. Vestibulum ante ipsum primis in
faucibus orci luctus et ultrices posuere cubilia curae; Pellentesque
sed sapien massa. Integer felis ligula, malesuada et arcu ut, viverra
pellentesque justo. Morbi congue, nisi a blandit ornare, enim felis
sagittis justo, nec ultrices ex dolor porttitor magna. Integer ut nibh
tempus, commodo orci imperdiet, sodales enim. Donec blandit nunc a
aliquam congue. Aenean placerat rhoncus massa, ut auctor massa tempor
vitae. Etiam ut lacus dignissim, bibendum purus in, egestas tellus.
</p>
<p>
Ut in lectus et risus varius tristique eu et nulla. Curabitur velit
nulla, pharetra nec porttitor ut, tempor at mi. Sed risus sapien,
hendrerit sit amet tortor sed, ultrices vehicula leo. Pellentesque sed
semper justo, et finibus justo. Morbi ultricies scelerisque magna,
eget accumsan leo aliquam quis. Sed vestibulum bibendum augue, ut
feugiat quam dictum vitae. Fusce hendrerit lectus sem, vel
sollicitudin ex viverra maximus.
</p>
</ol>
</div>
</div>
<!--Editor 2 -->
<div class="panel window-2">
<div class="panel-header">
<div class="tabs">
<div class="tab-item tab-item--selected">styles.less</div>
</div>
</div>
<div class="panel-body">
<ol class="editor-container">
<li class="editor-line"></li>
<li class="editor-line"><span class="editor-content">Hey there!</span></li>
<li class="editor-line"></li>
</ol>
</div>
</div>
</div><!--Editor ends-->
<!--Footer-->
<div class="footer">
<div class="footer-file-info">
<span class="file-info-source">src/styles.less</span>
<span class="file-info-location">2:5</span>
</div>
<div class="footer-controls">
<a href="">LF</a>
<a href="">UTF-8</a>
<a href="">Less</a>
<a href=""><span class="icon-git-branch"></span>master</a>
<a href="">⬇︎ 5 ⬆︎</a>
<a href=""><span class="icon-diff"></span>1 file</a>
<a href=""><span class="icon-squirrel"></span></a>
</div>
</div>
</div><!--Grid structure ends-->
<!-- Control Bar for demo purposes-->
<div class="control-bar">
<button id="window-1">Close Tabs to the Right</button>
<button id="window-2">Split Right</button>
</div>
/** Read the guide at: http://bit.ly/2xIdHu0 **/
/** Variables & Mixins **/
@bar-height: 30px;
.ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/** Scafolding --------------------**/
body {
margin: 0;
}
.page {
display: grid;
grid-template-rows: auto @bar-height;
grid-template-columns: 300px 1fr;
height: 100vh;
}
/** Panel Module **/
.panel {
display: grid;
grid-template-rows: @bar-height auto;
height: calc(~"100vh -" @bar-height);
}
.panel-body {
overflow: auto;
}
/** Tabs Module **/
.tabs {
display: grid;
grid-template-columns: repeat(3, 1fr);
height: 100%;
}
.tab-item {
.ellipsis;
text-align: center;
padding: 6px;
}
/** Editor **/
.editor {
display: grid;
.window-2 {
display: none;
}
&.editor--2-windows-layout {
grid-template-columns: 1fr 1fr;
.window-2 {
display: grid;
}
}
}
/** Footer **/
.footer {
display: grid;
grid-template-columns: 1fr auto;
grid-column-start: 1;
grid-column-end: 3;
}
.footer-file-info {
.ellipsis;
}
.footer-controls {
display: flex;
height: 100%;
justify-content: flex-end;
a {
height: 100%;
display: flex;
align-items: center;
}
}
/** Theme --------------------- **/
/** Icons
* From https://octicons.github.com/
**/
@font-face {
font-family: 'octicons';
src: url("data:application/x-font-ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwT1MvMg8SBSwAAAC8AAAAYGNtYXAXVtKPAAABHAAAAFRnYXNwAAAAEAAAAXAAAAAIZ2x5Zq+OrE4AAAF4AAAFQGhlYWQO9XO3AAAGuAAAADZoaGVhB8IDzgAABvAAAAAkaG10eCHAAKwAAAcUAAAANGxvY2EHRAkAAAAHSAAAABxtYXhwABcAaQAAB2QAAAAgbmFtZcgccnQAAAeEAAABknBvc3QAAwAAAAAJGAAAACAAAwL6AZAABQAAApkCzAAAAI8CmQLMAAAB6wAzAQkAAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAABAAADpCAPA/8AAQAPAAEAAAAABAAAAAAAAAAAAAAAgAAAAAAADAAAAAwAAABwAAQADAAAAHAADAAEAAAAcAAQAOAAAAAoACAACAAIAAQAg6Qj//f//AAAAAAAg6QD//f//AAH/4xcEAAMAAQAAAAAAAAAAAAAAAQAB//8ADwABAAAAAAAAAAAAAgAANzkBAAAAAAEAAAAAAAAAAAACAAA3OQEAAAAAAQAAAAAAAAAAA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FABYAIwADAAEECQAGABAAWQADAAEECQAKADQAsG9jdGljb25zAG8AYwB0AGkAYwBvAG4Ac1ZlcnNpb24gNi4xAFYAZQByAHMAaQBvAG4AIAA2AC4AMW9jdGljb25zAG8AYwB0AGkAYwBvAG4Ac29jdGljb25zAG8AYwB0AGkAYwBvAG4Ac1JlZ3VsYXIAUgBlAGcAdQBsAGEAcm9jdGljb25zAG8AYwB0AGkAYwBvAG4Ac0ZvbnQgZ2VuZXJhdGVkIGJ5IEljb01vb24uAEYAbwBuAHQAIABnAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAEkAYwBvAE0AbwBvAG4ALgAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=") format('truetype');
font-weight: normal;
font-style: normal;
}
[class^="icon-"], [class*=" icon-"] {
font-family: 'octicons' !important;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-squirrel:before {
content: "\e900";
}
.icon-repo:before {
content: "\e901";
}
.icon-git-branch:before {
content: "\e902";
}
.icon-diff:before {
content: "\e905";
}
/** Variables **/
@gray-dark: #2c313a;
@gray-base: #5c6370;
@gray-light: #c5cad3;
@gray-lighter: #d7dae0;
@gray-lightest: #dcdfe4;
@blue: #1f96ff;
@border-default: 1px solid @gray-light;
/** Styles **/
body {
background-color: @gray-lighter;
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
font-size: 0.8rem;
color: @gray-dark;
}
.sidebar {
border-right: @border-default;
.tree-group {
padding: 0;
margin: 0;
}
.tree-item {
padding: 5px 0 5px 25px;
list-style: none;
position: relative;
&:before {
font-family: 'octicons' !important;
position: absolute;
left: 10px;
}
&.tree-item--chevron-down:before {
content: "\e907";
}
&.tree-item--chevron-right:before {
content: "\e908";
}
}
.tree-item-label {
display: flex;
&:before {
font-family: 'octicons' !important;
font-size: 17px;
margin-right: 10px;
}
&.tree-item-label--repo:before {
content: "\e901";
}
&.tree-item-label--file-directory:before {
content: "\e903";
}
&.tree-item-label--file-text:before {
content: "\e904";
}
&.tree-item-label--file-book:before {
content: "\e906";
}
}
.panel-header {
display: flex;
align-items: center;
justify-content: center;
}
}
.editor {
.tab-item {
border-right: @border-default;
border-bottom: @border-default;
color: @gray-base;
&.tab-item--selected {
background-color: @gray-dark;
color: @gray-lightest;
border-color: @gray-dark;
}
}
.panel-body {
background-color: @gray-dark;
color: @gray-lightest;
font-family: "Courier New";
font-size: 1rem;
.editor-container {
padding-left: 45px;
margin-top: 0;
}
.editor-line {
color: @gray-base;
}
.editor-content {
color: @gray-light;
}
}
.window-2 {
border-left: 1px solid @gray-light;
}
}
.footer {
align-items: center;
border-top: @border-default;
}
.footer-file-info {
.file-info-source {
padding: 0 10px;
}
}
.footer-controls {
a {
padding: 0 10px;
color: initial;
text-decoration: none;
[class*="icon-"] {
font-size: 15px;
margin-right: 5px;
}
&:hover {
background-color: @gray-light;
}
.icon-squirrel {
color: @blue;
}
}
}
/** Control Bar for demo purposes **/
.control-bar {
position: fixed;
bottom: 50px;
right: 20px;
}
#window-1 {
display: none;
}
$( "#window-2" ).click(function (){
$( ".editor" ).addClass( "editor--2-windows-layout" );
$( "#window-1" ).show();
$( "#window-2" ).hide();
});
$( "#window-1" ).click(function (){
$( ".editor" ).removeClass( "editor--2-windows-layout" );
$( "#window-2" ).show();
$( "#window-1" ).hide();
});
Also see: Tab Triggers