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.
<!-- Check the HTML settings. We load the TypeKit fonts there -->
<section class="main-body">
<header>
<div class="logo-wrap">
<img src="http://res.cloudinary.com/bwt/image/upload/v1500839004/tech-geek-logo_efshzg.jpg" alt="Tech Geek" class="logo"> Tech Geek</div>
<nav class="mobile-nav">
<svg width="20" height="13" viewBox="0 0 20 13" xmlns="http://www.w3.org/2000/svg">
<path d="M1 1C.724 1 .5.776.5.5S.724 0 1 0h18c.276 0 .5.224.5.5s-.224.5-.5.5H1zm0 6c-.276 0-.5-.224-.5-.5S.724 6 1 6h18c.276 0 .5.224.5.5s-.224.5-.5.5H1zm0 6c-.276 0-.5-.224-.5-.5s.224-.5.5-.5h18c.276 0 .5.224.5.5s-.224.5-.5.5H1z" fill-rule="nonzero"/>
</svg><a href="#">Menu</a>
</nav>
<nav class="main-nav">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Technology</a></li>
<li><a href="#">Web design</a></li>
<li><a href="#">VR & Gaming</a></li>
</ul>
</nav>
</header>
<article>
<h1>SpaceX successfully launches reused Dragon spacecraft for ISS resupply</h1>
<p class="post-meta">June 11, 2017 by Joshua Gunn—<a href="#">Technology</a>, <a href="#"><span class="allsmallcaps">ISS</span></a>, <a href="#">Universe</a>.</p>
<p>SpaceX’s <span class="allsmallcaps">CRS-11</span> launch on Saturday was a success, bringing a Dragon spacecraft loaded down with nearly 6,000 lbs of supplies and research equipment on board to orbit. The twist was that SpaceX already sent this Dragon capsule up to resupply the International Space Station once before—back in September 2014, when it carried cargo to the <span class="allsmallcaps">ISS</span> prior to being recovered and refurbished post-mission.</p>
<blockquote class="big-quote">
“SpaceX is working on Dragon 2, a capsule designed to bring crew to and from the <span class="allsmallcaps">ISS</span>”.
</blockquote>
<p>The successful relaunch of a recycled Dragon is another historic milestone for SpaceX, which is aiming to reuse various parts of its launch and spacecraft equipment in order to help lower the cost of getting stuff to space. This is key to its aim of making launching a lucrative and profitable business, and also to it achieving its goal of flying missions, including crewed operations, to Mars.</p>
<h2>The goal of the mission</h2>
<p>After SpaceX’s Falcon 9 (not a reused one, this time) delivered the Dragon to orbit, it decoupled from the craft about 10 minutes after the original liftoff, and then deployed its solar wings to harvest energy for the rest of its trip to the <span class="allsmallcaps">ISS</span>.</p>
<img src="http://res.cloudinary.com/bwt/image/upload/v1500836264/iss_u5gjli.jpg" alt="ISS">
<p>The Dragon will attempt to dock with the <span class="allsmallcaps">ISS</span> around 36 hours from launch, when space station crew will attempt to capture the craft using the facility’s 57.7-foot Canadian-made robotic arm. If this Dragon completes the rest of its mission as planned, it’ll be recovered, refurbished and hopefully reused in a future mission.</p>
<p>SpaceX is working on Dragon 2, a capsule designed to bring crew to and from the <span class="allsmallcaps">ISS</span>, and hopes to run test flights with astronauts on board beginning next year.</p>
</article>
<small>Content adapted from Tech Crunch (<a href="https://techcrunch.com/2017/06/03/spacex-successfully-launches-reused-dragon-spacecraft-for-iss-resupply/">Source</a>)</small>
</section>
<aside class="sidebar">
<a href="#" class="twitter-link">@techGeek</a>
<h1>Popular posts</h1>
<ul>
<li><a href="#">Study suggests last-mile drone delivery could lower carbon footprint</a>
<p><em>2 days ago</em></p>
</li>
<li><a href="#">How to price your IPO</a>
<p><em>3 days ago</em></p>
</li>
<li><a href="#">Here are some reasons behind tech’s design shortage</a>
<p><em>5 days ago</em></p>
</li>
<li><a href="#">Here are some reasons behind tech’s design shortage</a>
<p><em>6 days ago</em></p>
</li>
</ul>
<img src="http://res.cloudinary.com/bwt/image/upload/v1500835373/ad_gfyhbx.jpg" class="carbon">
</aside>
// The SCSS is enabled as the CSS preprocessor
// Enable small caps
.allsmallcaps {
font-feature-settings: "c2sc", "smcp";
}
// Responsive variables
$phablet-breakpoint: 37em;
$tablet-breakpoint: 48em;
$desktop-breakpoint: 64em;
$large-desktop-breakpoint: 80em;
// Layout variables & mixins
$column: 6.25%;
@mixin width($number) {
width: #{ $number * $column };
}
@mixin offset($number) {
margin-left: #{ $number * $column };
}
// Fonts
$font-meta: "ff-meta-serif-web-pro", Georgia, serif;
$font-korolev: "korolev", sans-serif;
// Colours
$red: #F7412D;
// Variables
$base-font-size: 112.5; // Gets used as %, converts to 18px
$line-height: 1.45;
$base: ($base-font-size / 100); // We'll need this for some calculations
// Modular scale
$ratio: 1.5; // Perfect Fifth
// pow and ms functions
@function pow($number, $exponent) {
$value: 1;
@if $exponent > 0 {
@for $i from 1 through $exponent {
$value: $value * $number; //Multiply by $number if exponent less than zero
}
} @else if $exponent < 0 {
@for $i from 1 through -$exponent {
$value: $value / $number; //Divide by $number if exponent less than zero
}
}
@return $value;
}
@function ms($value, $ms-ratio: $ratio, $ms-base: $base){
$size: pow($ms-ratio, $value) * $ms-base;
@return #{ $size + "rem" };
}
// Vertical rhythm mixins
@mixin line-height($number) {
line-height: #{ $number * $line-height + 'rem'};
}
@mixin margin-top($number) {
margin-top: #{ $number * $line-height + 'rem'};
}
@mixin margin-bottom($number) {
margin-bottom: #{ $number * $line-height + 'rem'};
}
html {
font-size: 100%; // = 16 pixels
@media screen and (min-width: $tablet-breakpoint){
font-size: #{$base-font-size + '%'}; // 112.5% = 18 pixels
}
font-family: $font-meta;
color: #333;
}
// Set line-height and margins for all elements
* {
@include line-height(1);
@include margin-bottom(1);
@include margin-top(0);
}
// [ h1: font-size: [x value from scale], line-height: 2 * 30px, margin-top: 2 * 30px, margin-bottom: 1 * 30px ]
$headings: (
h1: (1, 1.5, 1, 1),
h2: (1, 1.5, 2, 0.5),
h3: (0, 1.5, 2, 0.5),
h4: (0, 1, 0.25, 0),
h5: (0, 1, 0.5, 0),
h6: (0, 1, 0.5, 0)
);
// Set line-heights and margins for headings
@each $heading, $properties in $headings {
#{$heading} {
font-size: ms(nth($properties, 1));
@include line-height(nth($properties, 2));
@include margin-top(nth($properties, 3));
@include margin-bottom(nth($properties, 4));
}
}
h1, h2, h3, h4, h5, h6 {
font-family: $font-korolev;
font-weight: 500;
}
.main-body {
@include width(14);
@include offset(2);
@media screen and (min-width: $desktop-breakpoint){
@include width(9);
@include offset(2);
float: left;
}
}
.post-meta {
color: #999;
a {
color: #999;
text-decoration: underline;
}
}
.sidebar {
@include width(13);
@include offset(2);
@media screen and (min-width: $desktop-breakpoint){
@include width(3);
@include margin-top(2);
@include offset(1);
float: left;
}
h1 {
text-transform: uppercase;
font-size: ms(0);
@include margin-top(2);
@include margin-bottom(0);
}
ul {
list-style: none;
padding: 0;
}
a {
font-family: $font-korolev;
display: block;
@include margin-bottom(0);
}
.carbon {
max-width: 265px;
}
}
header {
@include margin-top(2);
@include margin-bottom(1);
font-family: $font-korolev;
&:after {
content: "";
display: table;
clear: both;
}
@media screen and (min-width: $tablet-breakpoint){
margin-bottom: 0;
}
}
.mobile-nav {
float: right;
margin-right: 10%;
svg {
margin-bottom: 0;
margin-right: 10px;
fill: $red;
}
@media screen and (min-width: $tablet-breakpoint){
display: none;
}
}
.main-nav {
display: none;
@media screen and (min-width: $tablet-breakpoint){
display: inline-block;
}
ul {
list-style: none;
margin-bottom: 0;
}
li {
display: inline-block;
margin-right: 20px;
margin-bottom: 0;
}
}
.logo-wrap {
text-transform: uppercase;
font-size: ms(0);
display: inline;
float: left;
margin-right: 40px;
margin-bottom: 0;
img {
margin-bottom: 0;
}
}
.logo {
max-width: 48px;
float: left;
}
small, figcaption {
font-size: ms(-1);
}
.big-quote {
font-family: $font-korolev;
font-size: ms(0);
max-width: 90%;
font-weight: 300;
font-style: italic;
margin-left: 0;
@include line-height(1);
text-indent: -0.4em;
@media screen and (min-width: $phablet-breakpoint){
float: right;
max-width: 10em;
margin-left: 2em;
@include margin-bottom(0.5);
}
@media screen and (min-width: $large-desktop-breakpoint){
font-size: ms(1);
@include line-height(1.5);
}
}
article {
h1 {
font-style: normal;
@include offset(-1);
max-width: 100%;
@media screen and (min-width: $phablet-breakpoint){
font-size: ms(2);
@include line-height(2);
}
@media screen and (min-width: $tablet-breakpoint){
font-size: ms(3);
@include line-height(3);
max-width: 95%;
}
@media screen and (min-width: $desktop-breakpoint){
@include offset(-2);
max-width: 13em;
}
}
p {
max-width: 90%;
@media screen and (min-width: $tablet-breakpoint){
max-width: 33em;
}
}
img {
max-width: 100%;
}
}
a {
color: $red;
text-decoration: none;
&:hover {
color: lighten($red, 10%);
}
&:active {
color: lighten($red, 20%);
}
}
.twitter-link {
font-family: $font-korolev;
}
// Apply the baseline grid as background
.grid {
background-image: linear-gradient(to bottom, hsla(200, 100%, 50%, 0.3) 1px, transparent 1px);
background-repeat: repeat;
background-position: left top;
background-size: 100% #{($base-font-size / 100 * 16) * $line-height + "px"};
}
.double-grid {
@extend .grid;
background-image: linear-gradient(to bottom, hsla(200, 100%, 50%, 0.3) 1px, transparent 1px), linear-gradient(to bottom, hsla(200, 100%, 50%, 0.3) 1px, transparent 1px, transparent #{ 0.5 * ($base-font-size / 100 * 16) * $line-height + "px"}, hsla(200, 100%, 50%, 0.2) #{ 0.5 * ($base-font-size / 100 * 16) * $line-height + "px"}, transparent #{ 0.5 * ($base-font-size / 100 * 16) * $line-height + 1 + "px"}, transparent #{($base-font-size / 100 * 16) * $line-height + "px"});
}
Also see: Tab Triggers