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.
<main>
<h1>Inline and Block-Level Code</h1>
<p>
Testing styles for code that appears inline with content as well as blocks of code.
</p>
<p>
Updated 2 February 2016 with <a href="https://www.paciellogroup.com/blog/2016/02/short-note-on-improving-usability-of-scrollable-regions/">notes from Steve Faulkner on making scrolling bits keyboard friendly</a>.
</p>
<pre role="region" aria-label="Code sample; may scroll depending on viewport size." tabindex="0">main {
width: 80%;
margin: 1em auto;
padding: 1em 2em;
color: #000;
background-color: rgba(255,255,255,.25);
border: .07em solid rgba(0,0,0,.5);
border-radius: .5em;
} </pre>
<p>
Bacon ipsum dolor amet <code>hamburger venison ground round</code>, ham kielbasa magna dolor turducken ipsum brisket shank. Shank capicola boudin cow qui cupim id sirloin. Quis aliqua drumstick andouille veniam brisket sunt pork chop. <kbd>Alt</kbd> + <kbd>Prnt Scrn</kbd>. Pig pork chop id, beef ribs tenderloin turkey kielbasa sunt corned beef laboris quis brisket kevin short ribs drumstick. Pork pariatur velit ad tenderloin. Pancetta sirloin spare ribs corned beef prosciutto proident ut. Exercitation laboris pork belly picanha flank.
</p>
<p>
This is some text. You can <kbd>Ctrl</kbd> + <kbd>C</kbd> and then <kbd>Ctrl</kbd> + <kbd>V</kbd>. Maybe a <kbd>Tab<span class="Unicode">↹</span></kbd> for good measure.
</p>
<pre role="region" aria-label="Code sample; may scroll depending on viewport size." tabindex="0">/* For any clicks, clear the focus class from the nav and all its descendants, essentially closing the menu when a user clicks/taps outside of it. */
$(document).click(function(e) {
$("nav *, nav").removeClass("focus");
});
/* Manipulate focus classes in navigation. */
function classy(){
$("nav *, nav").removeClass("focus");
$("nav:focus").addClass("focus");
$("nav a:focus").addClass("focus");
$("nav a:focus").parentsUntil("body").addClass("focus");
}
/* Delay the assigning of classes to give the :focus a chance to catch up. There has to be a better way for this. */
$(document).keydown(function() {
setTimeout(classy, 200);
});
/* Find the current page and add the aria-label to its site structure parent, which you should only use if you can't do this server-side in your CMS of choice. */
$(document).ready(function() {
var el = $("a[aria-label^='Current Page']");
var elParent = el.parent().parent().parent("li").children("a");
var elTxt = elParent.text();
elParent.attr("aria-label", "Current Section: " + elTxt);
});</pre>
<p>
Aute prosciutto pork chop shank. Proident rump shank elit labore mollit sint brisket sausage culpa ham hock ipsum ullamco lorem fatback. Frankfurter ea commodo, ground round ham hock drumstick aliqua excepteur eiusmod picanha brisket lorem tenderloin sint strip steak. Sint aliquip leberkas, aliqua meatloaf swine id esse shank labore commodo fugiat porchetta. Salami proident capicola, rump ut pariatur sint sausage flank reprehenderit ground round. Sunt id ball tip, duis labore tail excepteur andouille do beef beef ribs aute rump sint. Dolore veniam kielbasa ullamco ad pork loin.
</p>
<p>
Ut tempor velit ad. Voluptate excepteur pastrami duis magna. Tail cupim voluptate excepteur officia hamburger corned beef qui in bacon est ball tip irure proident. Et kielbasa id magna eiusmod sint exercitation nostrud quis meatloaf elit landjaeger. Cow sint venison velit elit nulla. Cillum andouille pig et meatloaf.
</p>
<pre>
Testing an overflowing box with no keyboard support.
Laborum non ut, bresaola ground round elit ut swine leberkas.
Ea officia short loin swine.
Quis salami flank sint, do in ham hock anim tenderloin meatloaf dolore elit.
Deserunt turducken non kielbasa est ad aute quis aliquip fatback ball tip laboris ham hock in prosciutto.
Hamburger andouille pork loin reprehenderit meatloaf, ut swine porchetta pastrami veniam ham hock doner rump ad labore.</pre>
<p>
Frankfurter jerky shank tail ball tip biltong duis ground round chicken. Turducken meatloaf pork chop sausage mollit reprehenderit ball tip ribeye short ribs frankfurter hamburger salami. Pastrami ham hock eu leberkas pork belly boudin, consequat velit cow spare ribs irure dolore frankfurter. Meatball bresaola adipisicing shank. Ad pork loin consectetur, jowl boudin tempor swine nostrud ex. Pancetta fatback ut chicken cupidatat, sirloin eiusmod. Shank duis pork chop, dolore ham doner voluptate pork belly.
</p>
</main>
@import url(https://fonts.googleapis.com/css?family=Lato:400,700);
@import url(https://fonts.googleapis.com/css?family=Linden+Hill);
@import url(https://fonts.googleapis.com/css?family=VT323);
body {
background-color: #6D695C;
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAA3RSTlMmDQBzGIDBAAAAG0lEQVR42uXIIQEAAADCMHj/0NdkQMws0HEeAqvwAUGJthrXAAAAAElFTkSuQmCC);
font-size: 100%;
color: #fff;
font-family: Lato, Arial, sans-serif;
padding: 0;
margin: 0;
line-height: 1.4;
}
main {
width: 80%;
margin: 1em auto;
padding: 1em 2em;
color: #000;
background-color: rgba(255,255,255,.25);
border: .07em solid rgba(0,0,0,.5);
border-radius: .5em;
}
a {
color: #009;
}
h1 {
font-weight: normal;
font-family: 'Linden Hill', serif;
margin: .5em 0 0 0;
padding: 0;
font-size: 200%;
}
kbd {
border: 1px solid #aaa;
border-radius: 0.2em;
box-shadow: 0.1em 0.2em 0.2em rgba(0,0,0,.5);
background-color: #f9f9f9;
background-image: linear-gradient(to bottom, #eee, #f9f9f9, #eee);
padding: 0.1em 0.3em;
/*font-family: inherit;*/
font-family: Courier, "Courier New", monospace;
font-size: 90%;
color: #000;
white-space: nowrap;
}
code, pre {
font-family: 'VT323', 'Courier New', Courier, monospace;
font-size: 110%;
font-weight: normal;
color: rgba(255, 176, 0, 0.6);
background-color: #333;
background-image: linear-gradient(to bottom, #222, #222 50%, #000 50%, #000);
background-size: 100% 2px;
padding: .05em .5em;
text-shadow: rgba(185,128,0,.2) .5em 0 .2em;
}
pre {
border: .07em solid #222;
box-sizing: border-box;
padding: .5em 1em;
overflow: auto;
box-shadow: inset 0 0 4em rgba(0,0,0,.5);
border-radius: 1em;
background-image: linear-gradient(to bottom, rgba(255,255,255,.05), rgba(255,255,255,.15) .5em, rgba(255,255,255,.05) 2em, rgba(255,255,255,.05) 2em, rgba(255,255,255,0)),
/*linear-gradient(to left, rgba(255,255,255,.2), rgba(255,255,255,.05) 1em, rgba(255,255,255,.05) 1em, rgba(255,255,255,0)),*/
linear-gradient(to bottom, #222, #222 50%, #000 50%, #000);
background-size: /*100% 100%,*/ 100% 100%, 100% 2px;
}
code {
box-decoration-break: clone;
-webkit-box-decoration-break: clone;
}
pre:focus {
outline: .2em solid #0ff;
}
Also see: Tab Triggers