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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.
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.
If the stylesheet 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 CSS 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.
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="w3-mobile">
<div class="w3-container" style="padding: 5% 20% 0 20%">
<h1 class="headTitle">Random Quote Generator</h1>
<h4 class="headTitle">Click the <em>/New Quote/</em> button for a new Random Quote.<br>You can even "Tweet" your favorite Quotes to your friends too. Check out my other projects here on CodePen.io<br>If not, enjoy this Generator and thank you for stopping by.</h4>
<div class="w3-container w3-centered">
<button id="newQuote" class="w3-btn w3-ripple w3-xlarge w3-round-large w3-black w3-hover-green" onclick="quoGen()" style="font-family: 'Jim Nightshade', cursive">New Quote</button>
</div>
<div class="w3-container w3-card-4 w3-mobile" style="margin: 10% 5% 0 5%; padding: 0 5% 1% 5%; background-color: lightblue">
<div style="text-align: center">
<p id="quoteGenerator">Click the new quote button.</p>
</div>
<div id="tweet">
<a href="https://twitter.com/intent/tweet" class="twitter-share-button" data-url="https://codepen.io/OpenProCramMaker" data-size="large" data-text="Choose a new quote" data-via="cand1233" data-hashtags="generator" data-related="freeCodeCamp,CodePen" data-show-count="false">Tweet</a>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
</div>
</div>
<footer class="w3-center" style="color: white;"><i class="fa fa-code"></i> Coded by Chris Anderson <i class="fa fa-copyright"></i> freeCodeCamp <i class="fa fa-free-code-camp"></i></footer>
</div>
</div>
body {
background-color: darkblue;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='112' height='92' viewBox='0 0 112 92'%3E%3Cg fill='%24bac146' fill-opacity='0.25'%3E%3Cpath fill-rule='evenodd' d='M72 10H40L16 20H0v8h16l24-14h32l24 14h16v-8H96L72 10zm0-8H40L16 4H0v8h16l24-6h32l24 6h16V4H96L72 2zm0 84H40l-24-6H0v8h16l24 2h32l24-2h16v-8H96l-24 6zm0-8H40L16 64H0v8h16l24 10h32l24-10h16v-8H96L72 78zm0-12H40L16 56H0v4h16l24 14h32l24-14h16v-4H96L72 66zm0-16H40l-24-2H0v4h16l24 6h32l24-6h16v-4H96l-24 2zm0-16H40l-24 6H0v4h16l24-2h32l24 2h16v-4H96l-24-6zm0-16H40L16 32H0v4h16l24-10h32l24 10h16v-4H96L72 18z'/%3E%3C/g%3E%3C/svg%3E");
}
.backgroundDiv {
}
.headTitle {
text-align: center;
}
div h1 {
color: white;
font-size: 43px;
font-family: "Berkshire Swash", cursive;
}
div h4 {
color: lightgray;
font-size: 24px;
font-family: "Jim Nightshade", cursive;
}
#quoteGenerator {
font-family: "Jim Nightshade", cursive;
font-size: 38px;
}
footer {
font-family: 'IM Fell DW Pica SC', serif;
font-size: 14px;
color: white;
padding-bottom: 5px;
}
var quotes = [
"'The opposite of a correct statement is a false statement. But the opposite of a profound truth may well be another profound truth.' -Niels Bohr",
"'We accept the Love we think we deserve.' -Stephen Chbosky",
"'Inner peace begins the moment you choose not to let another person or event to control your emotions.' -Pema Chodron",
"'You must tell yourself 'No matter how hard it is, or how hard it gets, I'm going to make it.' -Les Brown",
"'If it won't matter in 5 years, don't spend more than 5 minutes getting angry about it.' -blacklinesuccess.com",
"'Think for Yourself. Trust your own Intuition. Another's mind isn't walking your journey, You are.' -Scottie Waves",
"'The secret of change is to focus all of your energy, not on fighting the old but on building the new.' -Socrates",
"'You'll never be as lazy as whoever named the fireplace.' -@longwall26",
"'Why fool around with a hamburger when you have a steak at home?' -Paul Newman",
"'I don't believe in pessimism. If something doesn't come up the way you want, forge ahead. If you think it's going to rain, it will.' -Clint Eastwood",
"'The best and most beautiful things in the world cannot be seen or even touched -they must be felt by the heart.' -Helen Keller"
];
var quote = "Open";
function quoGen() {
var randNum = Math.floor((Math.random() * quotes.length));
var randQuo = quotes[randNum];
quote = randQuo
document.getElementById("quoteGenerator").innerHTML = quote;
};
$("#newQuote").on("click", function(ev) {
ev.preventDefault();
$("#tweet iframe").remove();
var tweet = $("<a></a>")
.addClass("twitter-share-button")
.attr("data-size", "large")
.attr("href", "http://twitter.com/intent/tweet")
.attr("data-url", "false")
.attr("data-text", $("p:first").text())
.attr("data-via", "cand1233")
.attr("data-hashtags", "")
.attr("data-related", "freeCodeCamp,CodePen")
.attr("data-show-count", "false")
$("#tweet").append(tweet);
twttr.widgets.load();
});
Also see: Tab Triggers