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.
<h1 id="stop">Hashtag Links with Margin</h1>
<ol class="list">
<li><a href="#sone">Section One</a></li>
<li><a href="#stwo">Section Two</a></li>
<li><a href="#sthree">Section Three</a></li>
<li><a href="#sfour">Section Four</a></li>
</ol>
<h2 id="sone" class="xtarget">Section One <a class="up" href="#top">〈</a><a class="down" href="#stwo">〈</a></h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc eget tempus erat. Sed ipsum quam, scelerisque id sollicitudin eget, laoreet in tortor. Nulla semper ipsum arcu, eget tempor nisl egestas eu. Mauris aliquam, eros a lobortis eleifend, orci quam aliquam dui, nec ultricies dui nibh sit amet ante. Suspendisse id mattis mauris, nec hendrerit elit. Phasellus accumsan tristique enim in euismod. In sit amet nunc vel eros elementum dictum. Etiam rutrum diam ut dictum finibus. Nulla consequat fringilla orci a porttitor. Ut at consequat nisl. Nam ultricies tempor metus at sagittis. Curabitur ut blandit enim. Nulla eget accumsan diam, eu dapibus ipsum. Fusce orci leo, volutpat et sapien vel, gravida elementum arcu.</p>
<h2 id="stwo" class="xtarget">Section Two <a class="up" href="#sone">〈</a><a class="down" href="#sthree">〈</a></h2>
<p>In quis ultrices nibh. Morbi et urna dignissim, pretium magna nec, aliquam ex. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer semper justo eu sem tempor venenatis. Aenean elementum augue ante, sed consectetur metus efficitur id. Pellentesque varius lectus eget eleifend iaculis. Praesent posuere tellus non velit posuere pulvinar. Maecenas luctus dignissim suscipit. Ut vehicula erat a risus gravida sollicitudin. Suspendisse quam risus, tincidunt eu dapibus eu, suscipit id arcu.</p>
<h2 id="sthree" class="xtarget">Section Three <a class="up" href="#stwo">〈</a><a class="down" href="#sfour">〈</a></h2>
<p>Nullam consequat lectus eget magna interdum dapibus. Nam cursus aliquam commodo. Nullam interdum eleifend odio eu iaculis. Etiam convallis pellentesque erat, eget pharetra nulla tristique at. Proin auctor augue eleifend bibendum gravida. Phasellus pharetra hendrerit arcu sed suscipit. Proin quis maximus felis. Vestibulum pharetra lectus in metus sodales, ac volutpat augue euismod. Donec quis scelerisque augue, ullamcorper tincidunt nulla. Etiam tempor nibh ut tellus porttitor venenatis. Phasellus aliquam aliquet purus, sit amet luctus quam fermentum ultrices. Donec aliquam elit vel lectus sollicitudin lacinia lacinia gravida ipsum. Donec id justo nibh. Curabitur vulputate libero vitae lectus facilisis, vel mollis nisl fermentum. Vestibulum at ultrices nulla. Etiam feugiat sem eget turpis semper posuere.</p>
<h2 id="sfour" class="xtarget">Section Four <a class="up" href="#sthree">〈</a></h2>
<p>Integer ultrices efficitur tincidunt. Mauris sed leo eget ante cursus posuere. Mauris sit amet elit ut enim fermentum hendrerit eu in augue. Praesent vitae auctor tortor. Quisque pretium est vitae vehicula ultricies. Etiam libero nisi, molestie sit amet justo quis, fringilla tempor odio. Sed vitae nisl in nisi dictum bibendum. Integer porttitor, nunc in bibendum lobortis, ex nunc volutpat massa, eu vestibulum metus magna eget metus. Nunc eleifend placerat ante, sed interdum sem laoreet eget. Pellentesque et diam sed enim rutrum ornare. Donec eget velit in mi eleifend auctor. Nullam elementum nulla eu dui congue ultricies. Phasellus quis tellus eget nibh accumsan feugiat eu non risus.</p>
body { color:#777; font-family:'Lato', sans-serif; font-size:16px; line-height:1.714; max-width:600px; margin:24px auto 48px; padding:1.5em; }
a { color:#2bbbb3; text-decoration:none; -webkit-transition:.2s; transition:.2s; }
a:hover { color:#31d4cc; border-bottom:1px dotted; }
/* Style :target with margin & transition. The 's' can be changed to whatever works (I used it here to represent 'sections'). Adjust transition speed to .001s for instantaneous. */
.xtarget:target { color:#2bbbb3; margin-top:-12px; padding-top:60px; }
/* Add 'Currently Reading' to targeted section (optional) */
.xtarget:target:before { content:'Currently Reading'; font-family:'Open Sans', sans; font-size:12px; background:#ccc; border-radius:3px; background-clip:padding-box; color:#fff; padding:0 5px; position:absolute; top:24px; }
/* Navigation arrows for list items (optional) */
h1, h2 { color:#5e5e5e; font-family:'Georgia', Georgia, serif; font-weight:400; letter-spacing:-.025em; }
h1 { font-size:36px; }
h2 { position:relative; font-size:24px; margin:36px 0 12px; }
h2 a { font-size:16px; border:1px solid #efefef; border-radius:1000px; background-clip:padding-box; display:inline-block; width:24px; height:36px; line-height:38px; margin-left:15px; vertical-align:middle; }
h2 a:hover { color:#fff; background:#2bbbb3; }
h2 a.up {
-ms-transform:rotate(90deg); /* IE 9 */
-webkit-transform:rotate(90deg); /* Safari and Chrome */
transform:rotate(90deg); }
h2 a.down {
-ms-transform:rotate(-90deg); /* IE 9 */
-webkit-transform:rotate(-90deg); /* Safari and Chrome */
transform:rotate(-90deg); }
p { color:#777; font-size:18px; line-height:1.714; font-weight:300; letter-spacing:.01em; margin-bottom:24px; }
/* Hover Selectors to list (optional) */
.list li { position:relative; padding-bottom:6px; }
.list li:hover:before { content:'›'; color:#2bbbb3; position:absolute; left:-40px; line-height:1.2; }
Also see: Tab Triggers