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="quiz-container">
<h1>What Emoji is ChatGPT Describing?</h1>
<p id='info'>Description of Emoji: </p>
<div id="quiz"></div>
<div class="feedback" id="feedback"></div>
<div class="result" id="result"></div>
<div class="rainfall" id="rainfall"></div>
<p id='description'> People use ChatGPT as a tool every day. But how does ChatGPT describe things outside its dataset? How good is ChatGPT at recognizing new or out of context information?<br> <br> This quiz includes ChatGPT descriptions for various emoji-- some from after its training data ended. This means ChatGPT describes something completely unrelated to the actual emoji. But sometimes it describes the emoji just fine! This is the problem with relying on Language Models.<br> <br> If the description is "a cat making a kissy face" you input either the emoji (😽) or the exact <a href='https://emojipedia.org/kissing-cat'> emojipedia title</a> (Kissing Cat) to match the emoji to the description.<br> <br> Try and match emojis to the description, as written by ChatGPT 4. </p>
</div>
body {
font-family: Arial, sans-serif;
}
.quiz-container {
max-width: 600px;
margin: 0 auto;
text-align: center;
}
.quiz-item {
margin: 20px 0;
}
.quiz-item p{
font-size: 1.5em;
}
.quiz-item input {
font-size: 1.2em;
padding: 10px;
}
.quiz-item button {
font-size: 1.2em;
padding: 10px 20px;
cursor: pointer;
}
.feedback {
font-size: 1.2em;
margin-top: 20px;
}
.rainfall {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
overflow: hidden;
}
.rainfall span {
position: absolute;
font-size: 2em;
animation: fall linear infinite;
}
@keyframes fall {
0% { top: -10%; }
100% { top: 110%; }
}
#info {
font-size: .8em;
}
#description {
font-size: .8em;
}
const emojiQuizData = [
{ description: "A boomerang, a curved throwing tool that, when thrown correctly, returns to the thrower. Boomerangs are historically significant in Indigenous Australian culture, where they have been used for hunting and sport for thousands of years.", answer: "🫦", name: "Biting Lip" },
{ description: "Safety equipment worn by climbers to protect their head from potential impacts or falling debris while climbing. This emoji symbolizes outdoor adventure.", answer: "🫙", name: "Jar" },
{ description: "A low-heeled shoe, often known as a flat shoe or a slip-on shoe.", answer: "🫲", name: "Leftwards Hand" },
{ description: "A basket, typically woven from materials like straw, wicker, or bamboo, used for carrying or storing items.", answer: "🪺", name: "Nest with Eggs" },
{ description: "A mirrorball or disco ball, typically associated with dance parties and nightlife.", answer: "🫎", name: "Moose" },
{ description: "A face with a party horn and party hat", answer: "🥳", name: "Partying Face" },
{ description: "A ghost", answer: "👻", name: "Ghost" },
{ description: "A face with sunglasses", answer: "😎", name: "Smiling Face with Sunglasses" },
{ description: "A crutch, a medical device used to assist individuals with walking, especially those who have injuries or mobility impairments.", answer: "🫧", name: "Bubbles" },
{ description: "A DNA double helix, the iconic structure of genetic material found in the cells of all living organisms. The double helix consists of two long strands twisted around each other, forming a spiral staircase-like shape.", answer: "🪬", name: "Hamsa" },
{ description: "A melting face, with features appearing to droop or liquefy.", answer: "🫅", name: "Person with Crown" },
{ description: "A low-carb tortilla.", answer: "🫨", name: "Shaking Face" },
{ description: "A bar of soap.", answer: "🪼", name: "Jellyfish" }
];
let selectedQuestions = [];
let currentQuestion = 0;
let score = 0;
let usedEmojis = [];
const quizContainer = document.getElementById('quiz');
const feedbackContainer = document.getElementById('feedback');
const resultContainer = document.getElementById('result');
const rainfallContainer = document.getElementById('rainfall');
function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return array;
}
function loadQuestion() {
if (currentQuestion < selectedQuestions.length) {
const quizItem = document.createElement('div');
quizItem.className = 'quiz-item';
const questionDescription = document.createElement('p');
questionDescription.textContent = selectedQuestions[currentQuestion].description;
const inputLabel = document.createElement('label');
inputLabel.textContent = `Input the emoji you think is being described above: `;
const inputField = document.createElement('input');
inputField.setAttribute('type', 'text');
inputField.setAttribute('id', 'emoji-input');
inputField.setAttribute('placeholder', `Your answer here, e.g.,🤔 `);
const submitButton = document.createElement('button');
submitButton.textContent = 'Submit';
submitButton.onclick = checkAnswer;
quizItem.appendChild(questionDescription);
quizItem.appendChild(inputLabel);
quizItem.appendChild(inputField);
quizItem.appendChild(submitButton);
quizContainer.innerHTML = '';
quizContainer.appendChild(quizItem);
} else {
showResult();
}
}
function checkAnswer() {
const userInput = document.getElementById('emoji-input').value;
const correctAnswer = selectedQuestions[currentQuestion].answer;
const correctName = selectedQuestions[currentQuestion].name;
usedEmojis.push(correctAnswer);
feedbackContainer.textContent = `You said: ${userInput}, GPT was describing: ${correctAnswer} (${correctName})`;
if (userInput === correctAnswer || userInput.toLowerCase() === correctName.toLowerCase()) {
score++;
}
createRainfall(userInput, correctAnswer);
currentQuestion++;
setTimeout(() => {
feedbackContainer.textContent = '';
loadQuestion();
}, 3000);
}
function showResult() {
quizContainer.innerHTML = '';
resultContainer.textContent = `You scored ${score} out of ${selectedQuestions.length}!`;
createFinalRainfall();
}
function createRainfall(userEmoji, correctEmoji) {
rainfallContainer.innerHTML = ''; // Clear previous rainfall
for (let i = 0; i < 30; i++) {
const span = document.createElement('span');
span.textContent = Math.random() < 0.5 ? correctEmoji : userEmoji;
span.style.left = Math.random() * 100 + 'vw';
span.style.animationDuration = Math.random() * 3 + 2 + 's';
span.style.fontSize = Math.random() * 2 + 1 + 'em';
rainfallContainer.appendChild(span);
}
}
function createFinalRainfall() {
rainfallContainer.innerHTML = ''; // Clear previous rainfall
for (let i = 0; i < 100; i++) {
const span = document.createElement('span');
span.textContent = usedEmojis[Math.floor(Math.random() * usedEmojis.length)];
span.style.left = Math.random() * 100 + 'vw';
span.style.animationDuration = Math.random() * 3 + 2 + 's';
span.style.fontSize = Math.random() * 2 + 1 + 'em';
rainfallContainer.appendChild(span);
}
}
function initializeQuiz() {
selectedQuestions = shuffleArray([...emojiQuizData]).slice(0, 4);
loadQuestion();
}
initializeQuiz();
Also see: Tab Triggers