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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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.
<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>
<header id="header">
<img src="//cdn.kmp.link/img/tardis.png" alt="Tardis" id="header-img" />
<h1>TARDIS Crafters</h1>
<nav id="nav-bar">
<ul>
<li><a href="#features" class="nav-link">Features</a></li>
<li><a href="#tour" class="nav-link">Take a Tour</a></li>
<li><a href="#pricing" class="nav-link">Pricing</a></li>
</ul>
</nav>
</header>
<div class="container">
<form method="post" action="https://www.freecodecamp.com/email-submit" id="form">
<h3>Stay Up to Date</h3>
<input type="email" id="email" name="email" placeholder="Enter your email address">
<br/>
<input type="submit" value="Get Started" id="submit" class="btn" />
</form>
<h2 id="features">Features</h2>
<div id="features-box">
<div class="row">
<div class="features-img">
<img src="//cdn.kmp.link/img/tardis.png" alt="Tardis"/>
</div>
<div class="features-desc">
<h3>Bigger on the Inside</h3>
<p>Always a surprise to guests and companions. It may look small, but the Time Lord Scientists have perfected the manipulation of space-folding to fit everything you would ever need inside.</p>
</div>
</div>
<div class="row">
<div class="features-img">
<img src="//cdn.kmp.link/img/sonic-screwdriver.png" alt="Sonic Screwdriver"/>
</div>
<div class="features-desc">
<h3>Customied Sonics!</h3>
<p>Each TARDIS generates its own customized Sonic device, so your sonic screwdriver/trowel/blaster will match the look of your Console Room, and do just about everything*</p>
<p><small><em>* Some Sonic devices may not work on wood</em></small></p>
</div>
</div>
<div class="row">
<div class="features-img">
<img src="//cdn.kmp.link/img/key-security.png" alt="TARDIS Key"/>
</div>
<div class="features-desc">
<h3>Never Lose Your Keys Again</h3>
<p>Each TARDIS comes with backup keys in convenient locations, so you will never have to worry about losing your keys again.</p>
</div>
</div>
</div>
<h2 id="tour">Take a Tour</h2>
<div id="video-box" class="mx-auto">
<div data-video="5kjMCJ-7a3k" data-startseconds="0" data-endseconds="165" data-height="360" data-width="640" id="video">
</div>
</div>
<h2 id="pricing">Pricing</h2>
<div id="pricing-boxes">
<div class="pricing-box">
<h3>Type 40</h3>
<p><del>$2000</del> <strong><em>$100</em></strong></p>
<p>Great starter model</p>
<p>Navigation is as-is</p>
<p>Chameleon Circuit is stuck</p>
<button class="btn">Select</button>
</div>
<div class="pricing-box">
<h3>Type 50</h3>
<p><strong>$2000</strong></p>
<p>Easily cross dimensions</p>
<p>Seating for 500</p>
<p>Pool is piranha-free</p>
<button class="btn">Select</button>
</div>
<div class="pricing-box">
<h3>Type 87-A</h3>
<p><strong>$6000</strong></p>
<p>Voice-activated Navigation</p>
<p>Sonic Screwdriver Maintenance</p>
<p>Increased memory banks for your favorite consoles!</p>
<button class="btn">Select</button>
</div>
</div>
<footer>
<nav>
<ul>
<li><a href="#">Privacy</a><li>
<li><a href="#">Terms</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<br/>
<p>© TARDIS Crafters</p>
</footer>
</div>
body
margin-top: 90px
background-color: #eee
header
position: fixed
top: 0
width: 100%
background-color: rgba(51,102,204,.25)
height: 70px
padding: 10px
padding-left: 50px
padding-right: 50px
h1
float: left
line-height: 50px
font-family: 'Audiowide', cursive
img
height: 50px
float: left
.container h2
text-indent: -1000px
header nav
float: right
height: 70px
display: inline-block
margin: 0
padding: 0
ul
list-style: none
margin: 0
padding: 0
li
float: left
width: 160px
text-align: center
line-height: 40px
a
color: #000
display: block
&:hover
text-decoration: none
form
text-align: center
input[type='email']
width: 30%
input[type='submit']
width: 200px
margin: 20px
.btn
background-color: #fc0
font-weight: 900
text-transform: uppercase
padding: 7px
cursor: pointer
#video-box
width: 640px
#features-box
.row
width: 80%
min-width: 900px
margin: 40px auto
.features-img
float: left
height: 80px
width: 10%
line-height: 80px
font-size: 40pt
text-align: center
img
max-width: 100%
.features-desc
width: 90%
padding-left: 20px
footer
background-color: #ccc
padding: 10px
margin-top: 30px
text-align: right
overflow: auto
nav
width: 240px
nav, p
float: right
display: block
ul
list-style: none
margin: 0
padding: 0
li
width: 80px
float: left
a
text-decoration: none
display: block
text-align: center
color: #000
&:hover
text-decoration: none
#pricing-boxes
overflow: auto
display: flex
justify-content: space-around
.pricing-box
width: 300px
text-align: center
border: 1px #000 solid
border-radius: 5px
background-color: #fff
h3
padding: 10px
background-color: #dedede
font-size: 1.5em
button
margin-bottom: 10px
strong
font-size: 150%
@media screen and (max-width: 900px)
header h1
font-size: 125%
width: 150px
line-height: 25px
nav ul li
width: 125px
#pricing-boxes
display: block
width: 100%
.pricing-box
margin: auto
margin-bottom: 20px
function onYouTubeIframeAPIReady() {
var ctrlq = document.getElementById("video");
var player = new YT.Player('video', {
height: ctrlq.dataset.height,
width: ctrlq.dataset.width,
events: {
'onReady': function(e) {
e.target.cueVideoById({
videoId: ctrlq.dataset.video,
startSeconds: ctrlq.dataset.startseconds,
endSeconds: ctrlq.dataset.endseconds
});
}
}
});
}
Also see: Tab Triggers