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.
<!-- Main container -->
<section class="container">
<!-- Section context -->
<div class="context">
<div class="context__inner">
<h1>Link & CTA Styling</h1>
<p>Links are found in nearly all web pages. Links allow users to click their way from page to page. You can click on a link and jump to another destination. When you move the mouse over a link, the mouse arrow will turn into a little hand and the visual styling will adjust.</p>
</div>
</div>
<!-- /Section context -->
<!-- CTA examples -->
<div class="ctas">
<div class="ctas__inner">
<div class="ctas__inner-separator">
<a class="link" href="javascript:;">Standard text link</a>
</div>
<div class="ctas__inner-separator">
<a class="cta outline small" href="javascript:;">SM Outline</a>
</div>
<div class="ctas__inner-separator">
<a class="cta fill-blue small" href="javascript:;">SM Fill</a>
</div>
<div class="ctas__inner-separator">
<a class="cta fill-orange small" href="javascript:;">SM Fill</a>
</div>
<div class="ctas__inner-separator">
<a class="cta outline medium" href="javascript:;">MD Outline</a>
</div>
<div class="ctas__inner-separator">
<a class="cta fill-blue medium" href="javascript:;">MD Fill</a>
</div>
<div class="ctas__inner-separator">
<a class="cta fill-orange medium" href="javascript:;">MD Fill</a>
</div>
<div class="ctas__inner-separator">
<a class="cta outline large" href="javascript:;">LG Outline</a>
</div>
<div class="ctas__inner-separator">
<a class="cta fill-blue large" href="javascript:;">LG Fill</a>
</div>
<div class="ctas__inner-separator">
<a class="cta fill-orange large" href="javascript:;">LG Fill</a>
</div>
</div>
</div>
<!-- /CTA examples -->
</section>
<!-- /Main container -->
// Import fonts
@import url('https://fonts.googleapis.com/css?family=Fjalla+One|Libre+Franklin|Source+Sans+Pro');
// Variables
$orange: #DB633F;
$blue: #506B7F;
$blueDark: #2A3C48;
$blueGray: #BFD1DE;
$gray: #F1F4F7;
$white: #FFF;
$libre: 'Libre Franklin', sans-serif;
$source: 'Source Sans Pro', sans-serif;
$fjalla: 'Fjalla One', sans-serif;
// Load them fonts
html {
font-size: 62.5%;
font-weight: 400;
-webkit-font-smoothing: antialiased;
}
h1 {
font-size: 2.4rem;
line-height: 1;
letter-spacing: -0.25px;
font-family: $fjalla;
text-transform: uppercase;
text-align: left;
margin: 0 0 8px;
}
p {
font-size: 1.6rem;
line-height: 24px;
letter-spacing: 0.5px;
font-family: $source;
text-align: left;
}
// Page structure
.container {
width: percentage(12/12);
@media screen and (min-width: 1440px) {
display: flex;
flex-direction: row;
}
.context {
color: $blue;
background: $gray;
width: percentage(12/12);
display: flex;
flex-direction: row;
justify-content: center;
padding: 24px 0;
@media screen and (min-width: 768px) {
height: 35vh;
align-items: center;
padding: 0;
}
@media screen and (min-width: 1440px) {
width: percentage(4/12);
height: auto;
flex-direction: column;
align-items: stretch;
justify-content: flex-start;
padding: 80px 0 0 0;
}
&__inner {
width: percentage(10/12);
@media screen and (min-width: 768px) {
width: percentage(8/12);
}
@media screen and (min-width: 1440px) {
width: percentage(3/4);
padding: 0 percentage(0.5/4);
}
}
}
.ctas {
background: $white;
width: percentage(12/12);
display: flex;
flex-direction: row;
align-items: center;
padding: 24px 0;
@media screen and (min-width: 768px) {
height: 65vh;
justify-content: center;
padding: 0;
}
@media screen and (min-width: 1440px) {
width: percentage(8/12);
height: auto;
}
&__inner {
width: percentage(10/12);
@media screen and (min-width: 768px) {
width: percentage(8/12);
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: center;
}
@media screen and (min-width: 1440px) {
width: percentage(6/8);
padding: 80px 0;
}
&-separator {
margin: 24px 0 0;
&:first-child {margin: 0;}
@media screen and (min-width: 768px) {
margin: 24px 32px 0 0;
&:first-child {margin: 24px 32px 0 0;}
&:last-child {margin: 24px 0 0;}
}
@media screen and (min-width: 1440px) {
margin: 0 24px 40px 0;
&:first-child {margin: 0 24px 40px 0;}
&:last-child {margin: 0 0 40px;}
}
}
}
}
}
// Link & CTA styling
a {
transition: all 500ms cubic-bezier(0.19, 1, 0.22, 1);
// Text link
&.link {
font-family: 'Source Sans Pro', sans-serif;
font-size: 1.6rem;
line-height: 24px;
letter-spacing: 0.5px;
color: $orange;
text-decoration: underline;
// Hover state
&:hover {
color: darken($orange, 15%);
}
}
// CTA link
&.cta {
font-family: 'Libre Franklin', sans-serif;
font-size: 1rem;
line-height: 10px;
letter-spacing: 2px;
text-transform: uppercase;
text-decoration: none;
text-align: center;
display: inline-flex;
align-items: center;
justify-content: center;
&.outline {
color: $blue;
border: solid 1px $blue;
border-radius: 2px;
}
&.fill-blue {
color: $gray;
background: $blue;
border: solid 1px $blue;
border-radius: 2px;
}
&.fill-orange {
color: $gray;
background: $orange;
border: solid 1px $orange;
border-radius: 2px;
}
&.small {
min-width: 112px;
height: 40px;
}
&.medium {
min-width: 144px;
height: 48px;
}
&.large {
min-width: 224px;
height: 56px;
}
// Hover states
&:hover {
transform: scale(1.05);
&.outline {
color: darken($blue, 10%);
border: solid 1px darken($blue, 10%);
}
&.fill-blue {
background: darken($blue, 10%);
border: solid 1px darken($blue, 10%);
}
&.fill-orange {
background: darken($orange, 10%);
border: solid 1px darken($orange, 10%);
}
}
}
}
Also see: Tab Triggers