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.
<!--
This is a smiple project using javascript arrays, random number generator, string methods, and a jquery event handler.
Background jpg from https://subtlepatterns.com/
Fonts from Google Fonts
-->
<link href="https://fonts.googleapis.com/css?family=Cardo:400,400italic|Radley|Tangerine" rel="stylesheet">
<h1>Random Quotes Rewritten</h1>
<p>These are some of my favorite quotes I had collected during medical school I recently rediscovered via the wayback machine. I hope you enjoy them!</p>
<button class=button>New Quote</button>
<div class="quote"><span class = "saying"></span><br><span class = "author"></span></div>
<div class = link><a href="https://web.archive.org/web/20020204185254/http://www.pitt.edu/~smast27/">Original Site</a><div>
body {
text-align: center;
width: 600px;
margin: 0px auto;
background-color: #cdcdcd;
font-family: 'Tangerine', serif;
background: url(https://subtlepatterns.com/patterns/symphony.png);
}
h1{
text-shadow: 4px 4px 4px #aaa;
margin: 10px auto;
font-size: 4em;
color: #333;
}
p {
font-family: 'Radley', serif;
font-size: 1.2em;
text-align: left;
}
.quote {
font-family: 'Cardo', serif;
font-size: 1.5em;
width: 600px;
height: auto;
margin: 0 auto;
background-color: #efefef;
padding: 20px;
background-color: rgba(255,255,255,0.9);;
border-radius: 20px;
color: #000;
box-shadow: -10px 10px 20px rgba(100,100,100,.8);;
}
.author {
font-style: italic;
}
.button {
font-family: 'Tangerine', serif;
height: 50px;
width: 150px;
margin: 20px auto;
color: rgba(0,0,0,1);
background-color: rgba(160,200,160,.8);;
text-align: center;
font-size: 36px;
border-radius: 15px;
box-shadow: -5px 5px 10px rgba(100,100,100,.8);;
}
a {
position: absolute;
bottom: 0;
left: 0;
font-family: sans-serif;
font-size: 12pt;
}
$( document ).ready(function() {
generate();
function generate(){
var quotes = ["There are two types of people in this world. Those that enter a room and say 'Here I am!' and those that enter a room and say 'There you are!'.@Unknown","Because it's there.@George Mallory on climbing mountains","Footsteps always follow us, whenever it is snowing. They always show us where we've been, but never where we're going.@Winnie the Pooh's A-Z","For I know the plans that I have for you.@The Lord, Jer 29:11","The only way to climb properly is to realize that just getting up a route is nothing, the way it is done is everything.@Royal Robbins","Small minds discuss people. Average minds discuss events. Great minds discuss ideas.@Unkown","The significant problems we face cannot be solved at the same level of thinking we were at when we created them.@Albert Einstein","We must not cease from exploration and the end of all our exploring will be to arrive where we began and to know the place for the first time.@T S Eliot","One man asked another on the death of a mutual friend, 'How much did he leave?' His friend responded, 'He left it all.'@Proverb","It is more noble to give yourself completely to one individual than to labor diligently for the salvation of the masses.@Dag Hammarskjold, Sec. Gen. of the UN","Maps are a way of organizing wonder.@Edward Tufte","I have decided to make my life my argument.@Albert Schweitzer","Now it's a sqirt mecca for mystery artist, but back then it was just magic.@Jim Snyder on Kayaking","Knowledge keeps about as well as fish.@Alfred North Whitehead","It all began, I said, when I decided that some experts don't really know enough to make a pronouncement of doom on a human being. And I said I hoped they would be careful about what they said to others; they might be believed and that coud be the beginning of the end.@Norman Cousins, Anatomy of an Illness","Do not go gentle into that good night. Rage, rage against the dying of the light.@Dylan Thomas","For you will look smart and feel ignorant and the patient will not know which day it is for you and you will pretend to be smart out of ignorance.@John Stone, Gaudeamus Igitur"
];
randomQuote = quotes[Math.floor(Math.random()*quotes.length)];
quoteAuthor=randomQuote.split("@");
$('.saying').text(quoteAuthor[0]);
$('.author').text(quoteAuthor[1]);
}
$(".button").on( "click", function() {
generate();
});
});
Also see: Tab Triggers