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.
<a class="big-button" href="javascript:window.print()">Print</a>
<select id="mode">
<option selected>list</option>
<option>calendar</option>
</select>
<div id="events" class="list">
<div class="week"></div>
<div class="week"></div>
<div class="week"></div>
<div class="week">
<!-- example will be replaced by JS -->
<div class="day">
<div class="numeral">4/23</div>
<div class="events">
<a href="#">
<div class="title">Example Event</div>
<div class="info">
<div class="time">7:16:03 PM</div>
<div class="description">Lor separat existentie es un myth. Por scientie, musica, sport etc., li tot Europa usa li sam vocabularium. Li lingues differe solmen in.</div>
</div>
</a>
</div>
</div>
</div>
</div>
body {
max-width: 800px;
margin: 0 auto;
padding: 1em;
font-family: Lato, Helvetica, Arial, sans-serif;
}
@media print {
body{
padding:0;
}
}
.day{
color:#bbb;
}
.big-button {
display: block;
font-size: 120%;
border: solid 1px #5d584f;
background-color: #7b756d;
color: #64D4D0;
padding: 0.4em 0.1em 0.25em;
margin: 0.3em 0;
border-radius: 0.1em;
text-decoration: none;
text-align: center;
font-weight: 800;
text-shadow: 0px -1px 0 #303030;
box-shadow: 0 3px 0 #5d584f;
}
@media print {
.big-button,
#mode{
display:none;
}
}
#events {
border: 0;
font-size: 18px;
}
@media print {
#events {
font-size: 10px;
}
}
#events .numeral {
font-size: 200%;
}
#events a {
display: block;
text-decoration: none;
color: black;
}
#events a .title {
font-weight: 600;
font-size: 120%;
}
.calendar .week {
display: table-row;
page-break-inside: avoid;
}
.calendar .day {
display: table-cell;
vertical-align: top;
padding: 1em 0.25em;
min-width: 7em;
}
.calendar .events a {
margin-bottom: 0.25em;
border-bottom: solid 1px black;
}
.calendar .numeral {
font-size: 200%;
}
.calendar .description {
display: none;
}
.list .description {
text-align: justify;
text-justify: newspaper;
}
@media print {
.list {
column-width: 18em;
column-gap: 2em;
}
}
.list .day {
padding-bottom: 1em;
margin-bottom: 1em;
border-bottom: solid 1px black;
page-break-inside: avoid;
}
.list a {
margin-top:0.5em;
margin-bottom: 1.5em;
page-break-inside: avoid;
}
.list .time {
width: 25%;
}
.list .description {
width: 75%;
}
.list .info > * {
float: left;
}
.list .info:after {
content: '';
display: block;
float: none;
clear: both;
}
.list .empty.day {
display: none;
}
var events_el = document.getElementById('events');
var mode_el = document.getElementById('mode');
mode_el.onchange = function(event) {
events_el.classList.remove('calendar');
events_el.classList.remove('list');
events_el.classList.add(event.target.value);
// console.log(events_el.classList);
}
function loremIpsum(words){
var lipsum = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Epsum factorial non deposit quid pro quo hic escorol. Olypian quarrels et gorilla congolium sic ad nauseum. Souvlaki ignitus carborundum e pluribus unum. Defacto lingo est igpay atinlay. Marquee selectus non provisio incongruous feline nolo contendre. Gratuitous octopus niacin, sodium glutimate. Quote meon an estimate et non interruptus stadium. Sic tempus fugit esperanto hiccup estrogen. Glorious baklava ex librus hup hey ad infinitum. Non sequitur condominium facile et geranium incognito. Epsum factorial non deposit quid pro quo hic escorol. Marquee selectus non provisio incongruous feline nolo contendre Olypian quarrels et gorilla congolium sic ad nauseum. Souvlaki ignitus carborundum e pluribus unum. Li Europan lingues es membres del sam familie. Lor separat existentie es un myth. Por scientie, musica, sport etc., li tot Europa usa li sam vocabularium. Li lingues differe solmen in li grammatica, li pronunciation e li plu commun vocabules. Omnicos directe al desirabilit? de un nov lingua franca: on refusa continuar payar custosi traductores. It solmen va esser necessi far uniform grammatica, pronunciation e plu sommun paroles. Ma quande lingues coalesce, li grammatica del resultant lingue es plu simplic e regulari quam ti del coalescent lingues. Li nov lingua franca va esser plu simplic e regulari quam li existent Europan lingues. It va esser tam simplic quam Occidental: in fact, it va esser Occidental. A un Angleso it va semblar un simplificat Angles, quam un skeptic Cambridge amico dit me que Occidental es.".split(' ');
var start = Math.floor(Math.random() * lipsum.length);
return lipsum.slice(start,start+words).join(' ');
}
var date_time = new Date(Math.floor(Math.random()*1452003000000));
function loremTimesum(){
var date = new Date(Math.floor(Math.random()*1452003000000));
//q.setTime(q.valueOf() + 86400000);
console.log('date',date);
return date.toLocaleTimeString();
// return date.toDateString();
}
var date = new Date(Math.floor(Math.random()*1452003000000));
function getDay(){
var dateMonth = date.getMonth();
var dateDay = date.getDate();
var day = [
'<div class="day">',
'<div class="numeral">'+dateMonth+'/'+dateDay+'</div>',
'<div class="events"></div>',
'</div>'
].join('');
date = new Date(date.getTime() + 86400000);
return day;
}
var weeks = document.querySelectorAll('#events .week');
for(var week in weeks){
var days = [];
for(var i=0; i<7; i++){
days.push(getDay());
}
weeks[week].innerHTML = days.join('');
}
function generateEvents(){
var days = document.querySelectorAll('#events .day');
for(i=0; i<days.length; i++){
var empty = Math.random() < 0.2;
if(empty){
days[i].classList.add('empty');
}else{
var dayEvents = days[i].querySelector('.events');
var links = [];
var linkCount = Math.floor(Math.random()*12);
for(j=linkCount; j>0; j--){
var link = [
'<a href="#">',
'<div class="title">'+loremIpsum(4)+'</div>',
'<div class="info">',
'<div class="time">'+loremTimesum()+'</div>',
'<div class="description">'+loremIpsum(Math.floor(Math.random()*26)+4)+'</div>',
'</div>',
'</a>'
].join('');
links.push(link);
}
dayEvents.innerHTML = links.join('');
}
}
}
generateEvents();
Also see: Tab Triggers