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">
<!-- Japanese Boat -->
<div class="boat">
<div class="roof"></div>
<div class="cabin">
<div class="cabin-window"></div>
</div>
<div class="door-window"></div>
<div class="posts"></div>
<div class="lanterns">
<div class="lantern-1"></div>
<div class="lantern-2"></div>
<div class="lantern-3"></div>
<div class="lantern-4"></div>
<div class="lantern-5"></div>
<div class="lantern-6"></div>
<div class="lantern-7"></div>
<div class="lantern-8"></div>
<div class="lantern-9"></div>
<div class="lantern-10"></div>
<div class="lantern-11"></div>
<div class="lantern-12"></div>
</div>
<div class="rail-pole"></div>
<div class="rail-1"></div>
<div class="rail-2"></div>
<div class="side-wall"></div>
<div class="deck"></div>
<div class="hull"></div>
<div class="keel"></div>
<div class="bow"></div>
<div class="bow-tip"></div>
</div>
</div>
/* Japanese Boat */
/* Roof */
.roof {
position: absolute;
width: 380px;
height: 3px;
left: 23px;
top: 216px;
background: #af7c52;
}
.roof::after {
content: "";
position: absolute;
width: 380px;
height: 16px;
left: 0px;
top: -16px;
background: repeating-linear-gradient(
to right,
transparent,
transparent 45px,
#3eb26d 45px,
#3eb26d 45.5px,
transparent 45.5px,
transparent 57px
),
linear-gradient(#3fa060, #338950);
clip-path: polygon(4.5% 0%, 95.5% 0%, 100% 100%, 0% 100%);
}
/* Cabin */
.cabin {
position: absolute;
width: 330px;
height: 40px;
left: 48px;
top: 219px;
background: #9a6440;
}
.cabin::before {
content: "";
position: absolute;
width: 61px;
height: 33px;
left: 0px;
top: 7px;
background: #d4b69b;
}
/* Cabin Window */
.cabin-window {
position: absolute;
width: 265px;
height: 30px;
left: 61px;
top: 7px;
border: 1px solid #d9c0a2;
background: repeating-linear-gradient(
to right,
transparent,
transparent 13px,
#d4bba0 13px,
#d4bba0 14px
),
linear-gradient(to right, #7899cc, #607fab);
}
.cabin-window::before {
content: "";
position: absolute;
width: 265px;
height: 16px;
left: 0px;
top: 0px;
background: repeating-linear-gradient(
to right,
transparent,
transparent 6px,
#d4bba0 6px,
#d4bba0 7px
),
repeating-linear-gradient(
to bottom,
#f7faf8,
#f7faf8 3px,
transparent 3px,
transparent 4px
),
linear-gradient(#d4bba0, #d4bba0);
}
/* Posts */
.posts {
position: absolute;
width: 330.5px;
height: 39px;
left: 48px;
top: 219px;
background: linear-gradient(
to right,
#8d5429,
#8d5429 2px,
transparent 2px,
transparent 30px,
#8d5429 30px,
#8d5429 32px,
transparent 32px,
transparent 60px,
#8d5429 60px,
#8d5429 62px,
transparent 62px,
transparent 89.5px,
#814a20 89.5px,
#814a20 91.5px,
transparent 91.5px,
transparent 119px,
#814a20 119px,
#814a20 121px,
transparent 121px,
transparent 149px,
#814a20 149px,
#814a20 151px,
transparent 151px,
transparent 179px,
#814a20 179px,
#814a20 181px,
transparent 181px,
transparent 209px,
#814a20 209px,
#814a20 211px,
transparent 211px,
transparent 239px,
#814a20 239px,
#814a20 241px,
transparent 241px,
transparent 268px,
#814a20 268px,
#814a20 270px,
transparent 270px,
transparent 298px,
#814a20 298px,
#814a20 300px,
transparent 300px,
transparent 328px,
#814a20 328px,
#814a20 330px,
transparent 330px
);
}
/* Lanterns */
/* Lantern 1 */
.lantern-1 {
position: absolute;
width: 12px;
height: 13.5px;
left: 43px;
top: 220.5px;
background: repeating-linear-gradient(
#eaedeb,
#eaedeb 1.5px,
#f7faf8 1.5px,
#f7faf8 2px
);
border-radius: 50%;
}
.lantern-1::before {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: -0.8px;
background: #161a20;
}
.lantern-1::after {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: 13px;
background: #161a20;
}
/* Lantern 2 */
.lantern-2 {
position: absolute;
width: 12px;
height: 13.5px;
left: 73px;
top: 220.5px;
background: repeating-linear-gradient(
#d7000a,
#d7000a 1.5px,
#f62a2c 1.5px,
#f62a2c 2px
);
border-radius: 50%;
}
.lantern-2::before {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: -0.8px;
background: black;
}
.lantern-2::after {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: 13px;
background: black;
}
/* Lantern 3 */
.lantern-3 {
position: absolute;
width: 12px;
height: 13.5px;
left: 103px;
top: 220.5px;
background: repeating-linear-gradient(
#eaedeb,
#eaedeb 1.5px,
#f7faf8 1.5px,
#f7faf8 2px
);
border-radius: 50%;
}
.lantern-3::before {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: -0.8px;
background: black;
}
.lantern-3::after {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: 13px;
background: black;
}
/* Lantern 4 */
.lantern-4 {
position: absolute;
width: 12px;
height: 13.5px;
left: 132.5px;
top: 220.5px;
background: repeating-linear-gradient(
#d7000a,
#d7000a 1.5px,
#f62a2c 1.5px,
#f62a2c 2px
);
border-radius: 50%;
}
.lantern-4::before {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: -0.8px;
background: black;
}
.lantern-4::after {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: 13px;
background: black;
}
/* Lantern 5 */
.lantern-5 {
position: absolute;
width: 12px;
height: 13.5px;
left: 162px;
top: 220.5px;
background: repeating-linear-gradient(
#eaedeb,
#eaedeb 1.5px,
#f7faf8 1.5px,
#f7faf8 2px
);
border-radius: 50%;
}
.lantern-5::before {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: -0.8px;
background: black;
}
.lantern-5::after {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: 13px;
background: black;
}
/* Lantern 6 */
.lantern-6 {
position: absolute;
width: 12px;
height: 13.5px;
left: 192px;
top: 220.5px;
background: repeating-linear-gradient(
#d7000a,
#d7000a 1.5px,
#f62a2c 1.5px,
#f62a2c 2px
);
border-radius: 50%;
}
.lantern-6::before {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: -0.8px;
background: black;
}
.lantern-6::after {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: 13px;
background: black;
}
/* Lantern 7 */
.lantern-7 {
position: absolute;
width: 12px;
height: 13.5px;
left: 222px;
top: 220.5px;
background: repeating-linear-gradient(
#eaedeb,
#eaedeb 1.5px,
#f7faf8 1.5px,
#f7faf8 2px
);
border-radius: 50%;
}
.lantern-7::before {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: -0.8px;
background: black;
}
.lantern-7::after {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: 13px;
background: black;
}
/* Lantern 8 */
.lantern-8 {
position: absolute;
width: 12px;
height: 13.5px;
left: 252px;
top: 220.5px;
background: repeating-linear-gradient(
#d7000a,
#d7000a 1.5px,
#f62a2c 1.5px,
#f62a2c 2px
);
border-radius: 50%;
}
.lantern-8::before {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: -0.8px;
background: black;
}
.lantern-8::after {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: 13px;
background: black;
}
/* Lantern 9 */
.lantern-9 {
position: absolute;
width: 12px;
height: 13.5px;
left: 282px;
top: 220.5px;
background: repeating-linear-gradient(
#eaedeb,
#eaedeb 1.5px,
#f7faf8 1.5px,
#f7faf8 2px
);
border-radius: 50%;
}
.lantern-9::before {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: -0.8px;
background: black;
}
.lantern-9::after {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: 13px;
background: black;
}
/* Lantern 10 */
.lantern-10 {
position: absolute;
width: 12px;
height: 13.5px;
left: 311px;
top: 220.5px;
background: repeating-linear-gradient(
#d7000a,
#d7000a 1.5px,
#f62a2c 1.5px,
#f62a2c 2px
);
border-radius: 50%;
}
.lantern-10::before {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: -0.8px;
background: black;
}
.lantern-10::after {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: 13px;
background: black;
}
/* Lantern 11 */
.lantern-11 {
position: absolute;
width: 12px;
height: 13.5px;
left: 341px;
top: 220.5px;
background: repeating-linear-gradient(
#eaedeb,
#eaedeb 1.5px,
#f7faf8 1.5px,
#f7faf8 2px
);
border-radius: 50%;
}
.lantern-11::before {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: -0.8px;
background: black;
}
.lantern-11::after {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: 13px;
background: black;
}
/* Lantern 12 */
.lantern-12 {
position: absolute;
width: 12px;
height: 13.5px;
left: 371px;
top: 220.5px;
background: repeating-linear-gradient(
#d7000a,
#d7000a 1.5px,
#f62a2c 1.5px,
#f62a2c 2px
);
border-radius: 50%;
}
.lantern-12::before {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: -0.8px;
background: black;
}
.lantern-12::after {
content: "";
position: absolute;
width: 5px;
height: 1.5px;
left: 3.5px;
top: 13px;
background: black;
}
/* Door / Window */
.door-window {
position: absolute;
width: 11.5px;
height: 27px;
left: 86.5px;
top: 228px;
background: #62779e;
border: 1.5px solid #9e603c;
}
.door-window::before {
content: "";
position: absolute;
width: 5px;
height: 5px;
left: -33px;
top: 3px;
background: #62779e;
border: 1.5px solid #9e603c;
}
.door-window::after {
content: "";
position: absolute;
width: 5px;
height: 5px;
left: -23px;
top: 3px;
background: #62779e;
border: 1.5px solid #9e603c;
}
/* Rail */
.rail-pole {
position: absolute;
width: 323px;
height: 32px;
left: 95px;
top: 227px;
background: repeating-linear-gradient(
to right,
transparent,
transparent 14px,
#9b6b31 14px,
#9b6b31 16px,
transparent 16px
);
clip-path: path("M 0,14 C 94,21 260,10 323,0 L 323,13 C 290,28 94,34 0,29 Z");
}
.rail-1 {
position: absolute;
width: 411px;
height: 33px;
left: 12px;
top: 222px;
background: #bb835e;
clip-path: path(
"M 2,12 C 94,23 290,24 406,2.5 L 406,6 C 290,26 94,27 2,14.5 Z"
);
}
.rail-2 {
position: absolute;
width: 411px;
height: 25px;
left: 12px;
top: 231px;
background: #bb835e;
clip-path: path(
"M 82,17.5 C 120,20 280,24 406,2 L 406,6 C 290,26 82,24 82,20 Z"
);
}
/* Side Wall */
.side-wall {
position: absolute;
width: 80.5px;
height: 21px;
left: 15px;
top: 236px;
background: #e7d3bf;
clip-path: polygon(0% 0%, 100% 26%, 100% 100%, 0% 100%);
}
/* Deck */
.deck {
position: absolute;
width: 437px;
height: 41px;
left: 15px;
top: 228px;
background: #ad7a58;
clip-path: path("M 0,22 C 90,33 356,36 436,2 L 418,20 C 305,47 90,42 0,33");
}
.deck::before {
content: "";
position: absolute;
width: 437px;
height: 41px;
left: 0px;
top: -1px;
background: repeating-linear-gradient(
to right,
transparent,
transparent 2px,
#e9e9e9 2px,
#e9e9e9 12px,
transparent 10px,
transparent 18px
);
clip-path: path(
"M 0,26 C 105,38 369,36 436,6.5 L 420,17.5 C 330,42 90,43 0,31"
);
}
/* Hull */
.hull {
position: absolute;
width: 420px;
height: 46px;
left: 15px;
top: 247px;
background: #e6d3bf;
clip-path: path(
"M 0,13.5 C 90,23 295,27 420,0 L 400,40 L 29.5,50 L 29.5,26 L 0,21 Z"
);
}
/* Keel */
.keel {
position: absolute;
width: 358px;
height: 18px;
left: 44.5px;
top: 277px;
background: #cdad92;
clip-path: path("M 0,10 C 70,15 250,20 358,0 L 358, 20 L 0,20 Z");
}
/* Bow */
.bow {
position: absolute;
width: 108px;
height: 83px;
left: 376px;
top: 212px;
background: #e1c5ae;
clip-path: polygon(87% 0, 96% 22%, 31% 102%, 1% 100%);
}
.bow-tip {
position: absolute;
width: 24px;
height: 34px;
left: 466px;
top: 198px;
background: #338950;
clip-path: polygon(70% 5%, 91% 27%, 57% 95%, 14% 43%);
}
/* Body and Container Settings */
/* Center shapes */
body {
margin: 0;
padding: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
}
/* Set background and border color */
.container {
min-width: 500px;
height: 500px;
border: 5px solid lightgray;
background: transparent;
position: relative;
margin: 5px;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
}
Also see: Tab Triggers