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 class="codepen">Windows 8 style modal</h1>
<div class="codepen">
<button onclick="modal('hello there.')">Plain text example</button>
</div>
<p class="codepen">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse est augue, fringilla et est ut, egestas varius nisi. Nam quis arcu bibendum, elementum dui non, molestie arcu. Proin rhoncus semper orci, at porttitor leo placerat nec. Mauris tristique sem ac ultricies cursus. Sed pulvinar urna justo, ac bibendum nibh mattis sit amet. Phasellus sed lectus nunc. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Phasellus at ante sollicitudin, ornare erat a, adipiscing ligula. Aenean vel malesuada quam. Nunc consequat sodales est, eu vestibulum odio tristique eget. Nulla facilisi. Nam elit nisi, bibendum non lacus eu, elementum tincidunt quam.
</p>
<div class="codepen">
<button onclick="modal('<h4>Look i\'m HTML</h4><ul><li>Hello</li><li>Hello</li><li>Hello!</li></ul>')">HTML example</button>
</div>
<p class="codepen">
Praesent et dolor sed nulla egestas condimentum. Morbi ut porttitor dui. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec posuere arcu quis ultricies blandit. Pellentesque malesuada feugiat arcu eget auctor. Quisque adipiscing lacus urna, et vulputate nibh mollis ut. In tincidunt magna ut ipsum ultricies sodales. Phasellus sagittis odio odio, sit amet faucibus risus venenatis eget. Pellentesque id orci eleifend lectus porta pharetra. Maecenas non est lorem. Suspendisse sed pellentesque arcu. Fusce semper, sem id malesuada pretium, mauris nulla pretium enim, id pulvinar lorem ipsum et metus.
</p>
<p class="codepen">
Quisque semper, leo quis posuere vulputate, nisl est laoreet neque, quis lacinia libero risus laoreet elit. Donec malesuada urna at aliquam pellentesque. Donec ultrices risus eu risus pellentesque, id dictum nulla vulputate. Vestibulum at pretium ligula, a ullamcorper risus. Cras auctor urna eu dolor elementum, nec aliquet nulla molestie. Nulla ultricies lectus eget libero convallis cursus. Suspendisse vulputate facilisis metus, et volutpat mauris dictum a. Morbi fermentum massa id lacus molestie molestie. Suspendisse mollis dolor ut lectus rutrum varius. Suspendisse sed scelerisque lacus. Nam vehicula, neque eget dictum tristique, felis nisl dapibus nunc, a lobortis eros felis ut purus. Cras congue arcu nibh, pellentesque feugiat nibh aliquet et.
</p>
<p class="codepen">
Sed vitae molestie metus. Morbi quis laoreet urna, id tempor augue. Nullam sit amet mi tellus. Donec hendrerit molestie odio, non pretium est tempus non. Pellentesque quam risus, consequat vel sapien porta, commodo suscipit sem. Cras consequat volutpat arcu, ultrices auctor augue porta sit amet. Ut arcu neque, fringilla eget auctor vel, commodo a diam. Proin dolor dolor, consequat sodales nisl a, pulvinar pulvinar lacus. Nam tempor libero non nisl luctus consectetur.
</p>
<p class="codepen">
Cras vestibulum, magna ac accumsan dapibus, velit lorem semper dui, in feugiat sem neque sit amet metus. Vivamus condimentum nunc nulla, quis tincidunt urna volutpat sed. Donec pretium velit in turpis blandit auctor. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce dapibus lacinia tincidunt. Sed sed elit vel ipsum ultricies vulputate at sed ipsum. Quisque dignissim malesuada ligula, nec euismod eros hendrerit nec.
</p>
.modal-table{
position: fixed;
width: 100%;
height: 100%;
top: 0;
display: table;
}
.modal-cell{
display: table-cell;
vertical-align: middle;
background: rgba(0,0,0,0.90);
}
.modal-bar{
width: 100%;
background: #0f8845;
color: white;
/*margin: 0 auto;*/
}
.modal-content{
width: 50%;
padding: 1em;
margin: 0 auto;
position: relative;
}
.modal-content button{
bottom: 1em;
right: 1em;
position: absolute;
}
/* Irrelevent styling */
@font-face{
font-family: 'Open Sans Light';
src: local('Open Sans'), local('OpenSans'), url(http://themes.googleusercontent.com/static/fonts/opensans/v8/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff) format('woff');
}
body { height: 1000px; } /* Just to see scrolling working */
body{
margin: 0;
font-family: Open Sans;
}
*{ font-weight: lighter; }
.codepen{
text-align: center;
font-weight: lighter;
width: 50%;
margin: 10px auto;
}
button
{
border: 1px solid whitesmoke;
color: white;
background: #0f8845;
padding: .25em .5em;
cursor: pointer;
}
button:hover{
background: #0da24e;
}
var modal = function(html)
{
var modal_table = $('<div />') .addClass('modal-table'),
modal_cell = $('<div />') .addClass('modal-cell')
.appendTo(modal_table),
modal_bar = $('<div />') .addClass('modal-bar')
.appendTo(modal_cell),
modal_content = $('<div />') .addClass('modal-content')
.html(html)
.appendTo(modal_bar),
button = $('<button />') .appendTo(modal_content)
.text("Okay")
.click(function(){
modal_table.remove();
});
$('body').append(modal_table);
}
modal("Hello");
Also see: Tab Triggers