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="top-header">
<div class="wrapper nav-holder">
<nav class="main-nav">
<ul>
<li><a href="#hero">Home</a></li>
<li><a href="#portfolio">Portfolio</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</div>
<!-- /.wrapper -->
</div>
<!-- /.top-header -->
<div class="hero section" id="hero">
<div class="wrapper-small">
<article class="ta-center">
<img class="avatar" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/234228/avatar.jpg" alt="Avatar">
<h1 class="section-title">Diane Arbus</h1>
<p class="fs-large">
A picture is a secret about a secret, the more it tells you the less you know.
</p>
</article>
</div>
<!-- /.wrapper -->
</div>
<!-- /.hero -->
<div class="portfolio section" id="portfolio">
<div class="wrapper">
<h2 class="ta-center section-title">My Photos</h2>
<div class="grid grid--medium">
<figure>
<img src="https://unsplash.it/800/533/?image=397" alt="portfolio">
</figure>
<figure>
<img src="https://unsplash.it/800/533/?image=195" alt="portfolio">
</figure>
<figure>
<img src="https://unsplash.it/800/533/?image=377" alt="portfolio">
</figure>
</div>
<!-- /.grid -->
<div class="grid grid--medium">
<figure>
<img src="https://unsplash.it/800/533/?image=9" alt="portfolio">
</figure>
<figure>
<img src="https://unsplash.it/800/533/?image=260" alt="portfolio">
</figure>
<figure>
<img src="https://unsplash.it/800/533/?image=100" alt="portfolio">
</figure>
</div>
<!-- /.grid -->
</div>
<!-- /.wrapper -->
</div>
<!-- /.portfolio -->
<div class="about section" id="about">
<div class="wrapper">
<h2 class="ta-center section-title">About</h2>
<div class="grid grid--medium">
<article>
<h3>Photos By</h3>
<p>
<a href="https://pixabay.com/">Pixabay</a>, <a href="http://gratisography.com/">Gratisography</a> and <a href="https://unsplash.com/">Unsplash</a>. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eum, voluptatibus? Explicabo quam quae
repellat.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Placeat quisquam, eveniet consequuntur, alias quo consectetur illum voluptate, velit fugit vitae, cupiditate provident debitis repellat obcaecati! Cupiditate porro, esse corporis dicta?
</p>
</article>
<article class="column--light">
<h3>Prizes</h3>
<ul class="fs-small">
<li>Lorem ipsum dolor sit amet</li>
<li>Consectetur adipisicing elit</li>
<li>Reiciendis doloribus dolor enim neque suscipit est</li>
<li>Quasi architecto provident ab</li>
<li>Asperiores veritatis labore</li>
</ul>
<h4>Exhibitions</h4>
<ul class="fs-small">
<li>Lorem ipsum dolor sit amet</li>
<li>Consectetur adipisicing elit</li>
<li>Reiciendis doloribus dolor enim neque suscipit est</li>
<li>Quasi architecto provident ab</li>
<li>Asperiores veritatis labore</li>
</ul>
</article>
</div>
<!-- /.grid -->
</div>
<!-- /.wrapper -->
</div>
<!-- /.about -->
<div class="contact section" id="contact">
<div class="wrapper-small">
<h2 class="ta-center section-title">Contact Me</h2>
<form>
<label class="textfield">
<input type="text" />
<span class="textfield__label">Your name</span>
</label>
<label class="textfield">
<input type="email" />
<span class="textfield__label">Your email</span>
</label>
<label class="textfield">
<input type="tel" />
<span class="textfield__label">Your telephone</span>
</label>
<label class="textfield">
<textarea></textarea>
<span class="textfield__label">Your message</span>
</label>
<input type="submit" value="Send">
</form>
</div>
<!-- /.wrapper -->
</div>
<!-- /.contact -->
<footer class="footer section">
<div class="footer-top">
<div class="wrapper top-footer-content">
<div class="grid grid--medium">
<article>
<h4>Address</h4>
<p class="fs-small">
3 Abbey Road <br> London NW8 9AY
</p>
</article>
<article>
<h4>Let's connect</h4>
<ul class="connect-links">
<li><a href="#">twitter</a></li>
<li><a href="#">facebook</a></li>
</ul>
</article>
<article>
<h4>About Cutestrap</h4>
<p class="fs-small">
Cutestrap is a super lightweight CSS framework built with Sass. It's minimal, flexible, and easy to use.
</p>
</article>
</div>
<!-- /.grid -->
</div>
<!-- /.wrapper -->
</div>
<!-- /.footer-top -->
<div class="footer-bottom fs-small ta-center">
<p>A demo by <a href="#">Maria Antonietta Perna</a></p>
<p class="back-to-top"><a href="#hero">Top</a></p>
</div>
<!-- /.footer-bottom -->
</footer>
<!-- /.footer -->
//Google fonts
@import url(https://fonts.googleapis.com/css?family=Merriweather:300|Merriweather+Sans:400,700);
//VARIABLES
//colors
$primary-dark: #303F9F;
$primary: #3F51B5;
$primary-light: #C5CAE9;
$primary-color-text: #FFFFFF;
$accent-color: #FF9800;
$primary-text-color: #212121;
$secondary-text-color: #727272;
$divider-color: #B6B6B6;
$link: $accent-color;
$link--visited: lighten($accent-color, 10);
$link--hover: darken($link, 10%);
$link--active: $link--visited;
//typography
$base-font: 'Merriweather Sans',
sans-serif;
$heading: 'Merriweather',
serif;
//base styles
body {
font-weight: 400;
font-family: $base-font;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-weight: 300;
font-family: $heading;
}
a:link {
color: $link;
}
a:visited,
a:active {
color: $link--visited;
}
a:hover,
a:focus {
color: $link--hover;
}
//GENERAL
.btn,
input[type="submit"],
input[type="button"] {
background-color: $accent-color;
font-weight: 700;
text-transform: uppercase;
&:focus,
&:hover {
background-color: darken($accent-color, 10);
}
&:active {
background-color: $accent-color;
}
}
.section-title::after {
content: "--♥--";
display: block;
width: 100%;
}
.connect-links {
list-style-type: none;
display: flex;
margin-left: 0;
padding-left: 0;
li {
margin-right: 1rem;
&:last-child {
margin-right: 0;
}
a {
display: block;
}
}
}
.back-to-top {
position: absolute;
bottom: 10px;
right: 40px;
height: 30px;
width: 30px;
color: $primary-color-text;
a {
display: block;
height: 100%;
width: 100%;
line-height: 30px;
text-decoration: none;
font-weight: 700;
border-radius: 50%;
padding: 10px;
color: $primary-color-text;
background-color: $accent-color;
&:hover,
&:focus {
background-color: $link--hover;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.5);
}
}
}
//HEADER
.top-header {
background-color: rgba($primary-dark, .8);
}
//Top nav
.nav-holder {
padding: 0;
padding-top: 1.2rem;
}
.main-nav ul {
list-style-type: none;
display: flex;
padding-bottom: 1.2rem;
li {
margin-right: 1.4rem;
text-transform: uppercase;
&:last-child {
margin-right: 0;
}
a {
text-decoration: none;
display: block;
}
}
}
//SECTIONS
.section {
color: $primary-color-text;
}
//Hero section
.hero {
background-color: $primary;
height: 100vh;
min-height: 600px;
display: flex;
align-items: center;
padding: 2.4rem 0;
@media (min-width: 640px) {
padding-top: 2.4rem;
padding-bottom: 2.4rem;
}
}
.avatar {
width: 50%;
max-width: 300px;
height: auto;
margin-right: auto;
margin-left: auto;
margin-top: 1.2rem;
border-radius: 50%;
box-shadow: 0px 6px 3px rgba(0, 0, 0, .3);
}
//Portfolio
.portfolio {
background-color: $primary-light;
color: $primary-text-color;
}
//About
.about {
background: $divider-color url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/234228/about-bg.jpg) no-repeat fixed center / cover;
.section-title,
.grid {
background-color: rgba(0, 0, 0, .7);
}
article {
padding-left: 2.4rem;
padding-right: 2.4rem;
}
}
//Contact
.contact {
background: #B3E5FC url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/234228/contact-bg.jpg) no-repeat fixed center / cover;
}
//Footer
.footer-top {
background-color: $primary;
}
.top-footer-content {
padding-top: 1.6rem;
padding-bottom: 1.6rem;
}
.footer-bottom {
background-color: $primary-dark;
padding-top: 2.4rem;
}
Also see: Tab Triggers