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.
<main id="grid-container">
<header>
<h1 id="title">Retro Survey Form</h1>
<p id="description">Having lived the 80's as a kid allows me to have a first-hand perspective of what that decade was like. It had many great things, like anime and cutting edge technology, but also some not so great stuff, like hair styles and fashion. Are you into the '80s?</p>
</header>
<section>
<h2>Form</h2>
<form action="#" id="survey-form" method="POST">
<fieldset id="personal-info">
<legend>Personal information</legend>
<label for="name" id="name-label">
Name: <input type="text" id="name" placeholder="Kouji Kabuto" required>
</label>
<label for="email" id="email-label">
Email: <input type="email" id="email" placeholder="your@email.com" required> <!-- validate -->
</label>
<label for="number" id="number-label">
How much you love the 80's? <span>"not at all" (1) to "completely in love" (10)</span> <input type="number" id="number" placeholder="10" min="1"
max="10" required>
</label>
<label for="dropdown"> Favourite anime:
<select name="favourite" id="dropdown" required>
<option value="" selected disabled>Choose an option</option>
<option value="mazinger-z">Mazinger Z</option>
<option value="macross-robotech">Macross (Robotech)</option>
<option value="crusher-joe">Crusher Joe</option>
<option value="momo">Magical Princess Minky Momo</option>
<option value="gundam">Mobile Suit Zeta Gundam</option>
<option value="dragon-ball">Dragon Ball</option>
<option value="galactic-heroes">Legend of the Galactic Heroes</option>
</select>
</label>
</fieldset>
<fieldset id="cassette">
<legend>If I say compact cassette, you say...</legend>
<label for="pencil">
<input type="radio" name="cassette-match" value="pencil" id="pencil"> Pencil
</label>
<label for="roxette">
<input type="radio" name="cassette-match" value="roxette" id="roxette"> Roxette
</label>
<label for="not-born">
<input type="radio" name="cassette-match" value="not-born" id="not-born"> I wasn't born yet
</label>
</fieldset>
<fieldset id="alf">
<legend>ALF stands for...</legend>
<label for="always">
<input type="radio" name="alf" value="always" id="always"> Always Look Forward
</label>
<label for="alien">
<input type="radio" name="alf" value="alien" id="alien"> Alien Life Form
</label>
<label for="animals">
<input type="radio" name="alf" value="animals" id="animals"> Animals Living Fantastically-good
</label>
</fieldset>
<fieldset id="character">
<legend>What character represents you the most?</legend>
<label for="koji">
<input type="checkbox" name="character" value="koji" id="koji"> Kouji Kabuto
</label>
<label for="jem">
<input type="checkbox" name="character" value="jem" id="jem"> Jem
</label>
<label for="copper">
<input type="checkbox" name="character" value="copper" id="copper"> The Copper Kidd
</label>
<label for="larusso">
<input type="checkbox" name="character" value="larusso" id="larusso"> Daniel LaRusso
</label>
</fieldset>
<fieldset id="additional-comments">
<legend>Additional comments</legend>
<textarea name="additional-comments" id="textarea" cols="50" placeholder="I think the 80's is the best decade because..."></textarea>
</fieldset>
<div id="submit-button">
<input type="submit" value="Submit form" id="submit">
</div>
</form>
</section>
<div id="main-image" role="img" aria-label="Retro computers and devices from the 80's under a blue and violet light"></div>
</main>
<div id="glow-1"></div>
<div id="glow-2"></div>
<footer>
<p>Photo by <a href="https://unsplash.com/@lorenzoherrera?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText" target="_blank">Lorenzo Herrera</a> on <a href="https://unsplash.com/?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText" target="_blank">Unsplash</a></p>
<p>By Damian Demasi © - Since 1981</p>
</footer>
/* @font-face {
font-family: 'Karmatic Arcade';
src: url("../fonts/ka1.ttf");
font-weight: normal;
font-style: normal;
} */
/*
Codepen substitutions:
background-image: url(https://images.unsplash.com/photo-1550745165-9bc0b252726f?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1650&q=80);
font-family: 'karmatic-arcade-regular', sans-serif;
*/
/* Initial reset */
html {
box-sizing: border-box;
font-size: 16px;
}
*, *:before, *:after {
box-sizing: inherit;
margin: 0;
padding: 0;
/*outline: 1px dashed blue; /* Debugging purposes */
}
/* Grid */
@media screen and (max-width: 750px) { /* mobile devices */
#grid-container {
display: grid;
grid-template: .5fr auto 1fr / 1fr;
width: 100%;
}
#main-image {
grid-area: 1 / 1 / 2 / -1; /* top */
}
header {
grid-area: 2 / 1 / 3 / 2; /* middle */
height: min-content;
}
section {
grid-area: 3 / 1 / 4 / 2; /* bottom */
}
}
@media screen and (min-width: 750px) { /* small screens */
#grid-container {
display: grid;
grid-template: .5fr auto 1fr / 1fr;
width: 700px;
margin: 2rem auto 50px auto;
}
#main-image {
grid-area: 1 / 1 / 2 / -1; /* top */
border-radius: 10px 10px 0 0;
}
header {
grid-area: 2 / 1 / 3 / 2; /* middle */
height: min-content;
border-top: 1px solid rgb(26, 6, 18);
border-right: 1px solid rgb(26, 6, 18);
border-left: 1px solid rgb(26, 6, 18);
}
section {
grid-area: 3 / 1 / 4 / 2; /* bottom */
border-bottom: 1px solid rgb(10, 1, 4);
border-right: 1px solid rgb(10, 1, 4);
border-left: 1px solid rgb(10, 1, 4);
border-radius: 0 10px;
}
}
@media screen and (min-width: 1100px) { /* big screens */
#grid-container {
display: grid;
width: 1000px;
height: 900px;
grid-template: 1fr 1fr / 1fr 1fr;
margin: 5rem auto 50px auto;
}
#main-image {
grid-area: 1 / 1 / 3 / 2; /* the whole left column */
border-radius: 10px 0 0 10px;
}
header {
grid-area: 1 / 2 / 2 / 3; /* top right */
border-radius: 0 10px 0 0;
border-top: 1px solid rgb(26, 6, 18);
border-right: 1px solid rgb(26, 6, 18);
height: 100%;
}
header p {
line-height: 1.2em;
font-size: 1.1em;
}
section {
grid-area: 2 / 2 / 3 / 3; /* bottom right */
border-bottom: 1px solid rgb(10, 1, 4);
border-right: 1px solid rgb(10, 1, 4);
border-radius: 0 0 10px 0;
}
}
#grid-container {
flex-direction: row;
border-radius: 10px;
box-shadow: 0px -5px 70px 10px rgba(181, 83, 196, .3);
}
#main-image {
/* background-image: url(../img/lorenzo-herrera-p0j-mE6mGo4-unsplash.jpg); */
background-image: url(https://images.unsplash.com/photo-1550745165-9bc0b252726f?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1650&q=80);
background-repeat: no-repeat;
background-position: 45%;
background-size: cover;
order: -1;
}
header, section {
background-color: white;
}
/* Form */
form {
margin: 10px;
font-family: 'Nanum Gothic', sans-serif;
}
h1 {
margin-top: 10px;
/* font-family: "Karmatic Arcade", sans-serif; */
font-family: 'karmatic-arcade-regular', sans-serif;
text-align: center;
background: linear-gradient(90deg, #A4155B, #028CFD);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
h2 {
display: none;
}
header p {
padding: 1em 10px 1em 10px;
font-family: 'Nanum Gothic', sans-serif;
}
fieldset {
padding: 10px;
border: 1px solid rgba(26, 6, 18, .3);
border-radius: 10px;
margin-bottom: 1rem;
}
legend {
text-align: center;
}
span {
order: 1;
font-size: .7em;
margin-left: 1em;
width: 33%;
}
#personal-info {
display: flex;
flex-direction: column;
align-items: stretch;
}
#personal-info label {
display: flex;
margin: .3rem 0;
align-items: center;
}
#personal-info input, #personal-info select {
flex: 1 1 auto;
margin-left: 1em;
padding: 2px 4px;
height: 2rem;
border: 1px solid rgba(26, 6, 18, .3);
border-radius: 5px;
}
#cassette {
display: flex;
flex-direction: row;
justify-content: space-around;
}
#alf {
display: flex;
flex-direction: row;
flex-flow: column;
justify-content: space-around;
}
#character {
display: flex;
flex-direction: row;
flex-flow: column;
justify-content: space-around;
}
#additional-comments {
display: flex;
}
#additional-comments textarea {
flex: 1 1 auto;
padding: 2px;
max-width: 100%;
border: 1px solid rgba(26, 6, 18, .3);
border-radius: 5px;
resize: vertical;
/* will prevent resizing horizontally */
}
#submit-button {
display: flex;
}
input[type=submit] {
flex: 1 1 auto;
background-color: #832D7C;
/* fallback */
background-image: linear-gradient(90deg, #00B7FD, #C54F9C);
border: none;
border-radius: 10px;
color: white;
padding: .8rem;
margin: 4px 2px;
font-size: 1.2rem;
cursor: pointer;
box-shadow: 0 5px 10px rgba(181, 83, 196, .5);
height: 3rem;
}
input[type=submit]:hover {
box-shadow: 0 2px 5px rgba(181, 83, 196, 1);
transition: all .3s;
font-size: 1rem;
padding: 1rem;
height: 3rem;
}
/* Glow */
#glow-1 {
width: 850px;
/* TODO media query */
margin: -60px auto;
box-shadow: 0px 40px 80px 10px #0ff;
}
#glow-2 {
width: 650px;
/* TODO media query */
margin: -60px auto;
box-shadow: 0px 80px 80px 20px rgb(181, 83, 196);
}
/* Footer */
footer {
display: flex;
margin-top: 15rem;
flex-direction: column;
justify-content: center;
font-family: 'Nanum Gothic', sans-serif;
}
footer * {
margin: 0 auto 2rem;
}
footer p:first-child {
font-style: italic;
margin-bottom: 1em;
}
// coded by @lasjorg
// eslint-disable-next-line no-unused-vars
const projectName = 'survey-form';
Also see: Tab Triggers