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>
<h1>Your Account</h1>
<form action="" method="post">
<nav>
<a href="#0" class="active">Sign In</a>
<a href="#0">Create Account</a>
</nav>
<div class="form-field">
<label for="email">Email Address</label>
<input type="email" id="email" name="email">
</div>
<div class="form-field">
<label for="password">Password</label>
<input type="password" id="password" name="password">
</div>
<input type="submit" value="Sign In" class="button">
</form>
<a href="#0" class="forgot-password">Forgot your password?</a>
</main>
/* This ruleset is the only thing added to the original Pen... to get the boxes+dots at the corners of the form */
form {
--line: linear-gradient(to right, var(--brown), var(--brown));
--dot: radial-gradient(circle, rgb(170, 139, 89) 1px, rgba(170, 139, 89, 0) 1px);
--box:
var(--line),
var(--line),
var(--dot);
--box-size:
2px 10px,
12px 2px,
10px 10px;
background-repeat: no-repeat;
background-image:
var(--box),
var(--box),
var(--box),
var(--box);
background-size:
var(--box-size),
var(--box-size),
var(--box-size),
var(--box-size);
background-position:
/* top left */
10px 0px,
0px 10px,
0px 0px,
/* top right */
right 10px top 0px,
right 0px top 10px,
100% 0%,
/* bottom left */
left 10px bottom 0px,
left 0px bottom 10px,
0% 100%,
/* bottom right */
right 10px bottom 0px,
right 0px bottom 10px,
100% 100%;
}
form {
border: 7px double #AA8B59;
padding: 3rem;
}
:root {
--brown: #AA8B59;
--gray: rgb(14, 19, 25);
--gray--t: rgba(14, 19, 25, 0);
--body-font: 'Josefin Sans', sans-serif;
}
* {
box-sizing: border-box;
}
html {
font-family: var(--body-font);
font-size: 90%;
color: white;
text-align: center;
background: var(--gray) url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="28" height="49" viewBox="0 0 28 49"%3E%3Cg fill-rule="evenodd"%3E%3Cg id="hexagons" fill="%239C92AC" fill-opacity="0.1" fill-rule="nonzero"%3E%3Cpath d="M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z"/%3E%3C/g%3E%3C/g%3E%3C/svg%3E');
}
body {
margin: 0;
height: 100vh;
display: grid;
place-items: center;
background: linear-gradient(
var(--gray) 30%, var(--gray--t)
);
}
main {
width: 600px;
@media(max-width: 610px) {
width: 320px;
form { padding: 2rem; }
nav { display: flex; justify-content: space-between; }
nav a { margin: 0; }
}
}
h1 {
font-family: 'Crimson Text', serif;
font-size: 3.4rem;
letter-spacing: -0.06rem;
}
nav {
text-transform: uppercase;
letter-spacing: 0.1rem;
margin: 0 0 2rem 0;
a {
display: inline-block;
padding: 0.3rem 0;
margin: 0 1rem;
&.active {
border-bottom: 2px solid var(--brown);
}
}
}
a {
color: inherit;
text-decoration: none;
}
.form-field {
margin: 0 0 1rem 0;
&:focus-within {
label {
color: white;
}
}
}
label {
display: block;
text-align: left;
color: #7C7C7C;
}
input {
width: 100%;
background: none;
border: 2px solid #7C7C7C;
padding: 1.5rem;
&:focus {
border-color: white;
outline: 0;
}
}
.button {
background: var(--brown);
color: white;
border: 0;
font-family: var(--body-font);
text-transform: uppercase;
padding: 1.5rem;
font-size: 1.0rem;
letter-spacing: 0.1rem;
}
.forgot-password {
display: block;
margin: 2rem 0;
text-transform: uppercase;
letter-spacing: 0.1rem;
opacity: 0.9;
}
Also see: Tab Triggers