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.
<div class="container h-100">
<div class="row align-items-center justify-content-center h-100">
<div class="col-md-8 col-lg-6 p-3">
<div class="bg-light shadow p-5">
<div id="citation" class="text-center">
La vie est un mystère qu'il faut vivre, et non un problème à résoudre.
</div>
<div class="bg-secondary w-25 mx-auto p-1 my-4"></div>
<div id="auteur" class="text-center">
Gandhi
</div>
</div>
<div id="nouveau" class="mt-2 text-center p-3 text-white font-weight-bold text-uppercase">
Nouvelle citation
</div>
</div>
</div>
</div>
html, body {
background: #5C258D;
background: -webkit-linear-gradient(to right, #4389A2, #5C258D);
background: linear-gradient(to right, #4389A2, #5C258D);
height: 100%;
min-width: 500px;
}
#citation {
font-size: 2em;
font-family: 'Satisfy', curve;
line-height: 1.3em;
letter-spacing: 1px;
}
#citation:before {
content: open-quote;
}
#citation:after {
content: close-quote;
}
#auteur {
font-size: 1.5em;
font-style: italic;
}
#nouveau {
background: #ff9966;
background: -webkit-linear-gradient(to right, #ff5e62, #ff9966);
background: linear-gradient(to right, #ff5e62, #ff9966);
cursor: pointer;
}
// Variables DOM
const buttonQuote = document.querySelector("#nouveau"); // button
const quoteContent = document.querySelector("#citation"); //textContent
const quoteAuthor = document.querySelector("#auteur"); //AuthornName
// Array quote
const quote = [
[
"La vie est un mystère qu'il faut vivre, et non un problème à résoudre.",
"Gandhi",
],
["Le plus grand risque est de ne prendre aucun risque.", "Mark Zuckerberg"],
["Méritez votre statut de leader chaque jour.", "Mickael Jordan"],
["Soyez le changement que vous voulez voir dans le monde.", "Gandhi"],
[
"A chaque fois que vous vous retrouvez du même côté que la majorité, il est temps de prendre du recul, et de réfléchir.",
"Mark Twain",
],
[
"Seulement ceux qui prendront le risque d’aller trop loin découvriront jusqu’où on peut aller.",
"T.S Elliot",
],
["Le succès c’est tomber sept fois, se relever huit.", "Proverbe japonais"],
[
"Dans vingt ans vous serez plus déçus par les choses que vous n’avez pas faites que par celles que vous avez faites. Alors sortez des sentiers battus. Mettez les voiles. Explorez. Rêvez. Découvrez.",
"Mark Twain",
],
[
"Si vous attendez pour agir, tout ce que vous gagnerez, avec le temps, c’est de l’âge.",
"Brian Tracy",
],
[
"Quand on concentre son attention sur un seul projet, l’esprit suggère constamment des idées et des améliorations qui lui échapperaient s’il était occupé avec plusieurs projets en même temps.",
"P.T. Barnum",
],
[
"Se dédier à faire tout ce que l’on peut pour aider les autres à obtenir ce qu’ils veulent, c’est la clé du succès.",
"Brian Sher",
],
[
"Si vous pensez que vous êtes trop petit pour avoir de l’impact, essayez d’aller au lit avec un moustique.",
"Anita Roddick",
],
[
"Ne jugez pas chaque jour sur ce que vous récoltez, mais sur les graines que vous semez.",
"Robert Louis Stevenson",
],
["L’action est la clé fondamentale de tout succès.", "Pablo Picasso"],
[
"Le succès, c’est se promener d’échecs en échecs tout en restant motivé.",
"Winston Churchill",
],
[
"Votre avenir est créé par ce que vous faîtes aujourd’hui, pas demain.",
"Robert T. Kiyosaki",
],
[
"Ne vous découragez pas, c’est souvent la dernière clef du trousseau qui ouvre la porte.",
"Zig Ziglar",
],
[
"Pour gagner votre vie, apprenez à l’école. Pour gagner une fortune, apprenez par vous-même.",
"Brian Tracy",
],
[
"Les gagnants trouvent des moyens, les perdants des excuses…",
"F. D. Roosevelt",
],
[
"Vous n’êtes jamais trop vieux pour vous fixer de nouveaux buts, ou rendre vos rêves réalité.",
"C.S. Lewis",
],
[
"Un pessimiste voit la difficulté dans chaque opportunité. Un optimiste voit une opportunité dans chaque difficulté.",
"Winston Churchill",
],
];
// Using my variable randomIndex, I will generate a random quote, using randomQuote[0] for the quote and randomQuote[1] for the author's name.
buttonQuote.addEventListener("click", () => {
const randomIndex = Math.floor(Math.random() * quote.length);
const randomQuote = quote[randomIndex];
quoteContent.textContent = randomQuote[0];
quoteAuthor.textContent = randomQuote[1];
});
Also see: Tab Triggers