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.
<header class="site-header">
<img src="https://dbwebb.se/img/htmlphp/guide/murphy/murphy-logo.jpg" alt="logo">
<span class="site-title">Stormtrooper-Murphy</span>
<span class="site-slogan">Deathstar's finest.</span>
</header>
<nav class="navbar">
<a href="index.html" class="selected">Home</a>
<a href="about.html">About</a>
</nav>
<main>
<article>
<header>
<h1>This is a Stormtrooper</h1>
<p class="author">Updated <time datetime="2018-06-25 11:17:43">25th June 2018</time> by Murphy</p>
</header>
<img src="https://dbwebb.se/img/htmlphp/guide/murphy/murphy-me.jpg" alt="This is me!" class="me">
<p>
Stormtroopers get a bad rap – the army of the Dark Lord of the Sith in the original Star Wars films is probably best known for its lack of aim, even at close range. Stormtroopers were tricked, manipulated, out-maneuvered, shot at, and defeated repeatedly by the heroes of the franchise.
</p>
<p>
Contrary to what many fans believed after the prequel trilogy, stormtroopers are not clone troopers. The clone soldiers that were created on Kamino aged more quickly than other humans and died prematurely, and so, the clone troopers had been replaced by Imperial stormtroopers, who were recruited and trained at Imperial Academies.
</p>
<p>
The name "stormtrooper" comes from the German "Stoßtruppe", which was the name given to shock troopers in World War I and World War II. The stormtroopers were the men on the front lines, trying to infiltrate enemy trenches. They had high casualties, because they were at the center of the action, putting their lives in harm’s way.
</p>
<footer class="byline">
<img class="byline-me" src="https://dbwebb.se/img/htmlphp/guide/murphy/murphy-byline.jpg" alt="byline image of me!">
<p>
Stormtrooper-Murphy worked at the "Deathstar" during the weeks. It was a pretty unappreciated work with close to no freetime. When Murphy has a couple of minutes over, the fine art of square-dance is practiced to perfection with the fellow troopers. Murphy is the 5679th best shooter in the squad and a life-long dream is to see Disney World sometime, someday...
</p>
</footer>
</article>
</main>
<footer class="site-footer">
<hr>
<a href="http://validator.w3.org/check/referer">HTML5</a>
<a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a>
<a href="http://validator.w3.org/unicorn/check?ucn_uri=referer&ucn_task=conformance">Unicorn</a>
</footer>
html {
background-image: url("https://dbwebb.se/img/htmlphp/guide/murphy/background.jpg");
background-attachment: fixed;
background-position: bottom right;
background-color: black;
background-repeat: no-repeat;
overflow-y: scroll;
}
body {
background-color: #ddd;
width: 1000px;
margin: 8px auto;
border: 1px solid black;
}
.site-header {
background-color: #292a2e;
color: white;
overflow: auto;
}
.site-header img {
float: left;
}
.site-title {
display: block;
padding-top: 1em;
padding-left: 50px;
font-size: 46px;
overflow: auto;
}
.site-slogan {
display: block;
padding-left: 50px;
font-style: italic;
font-size: 28px;
overflow: auto;
}
.site-footer {
height: 70px;
margin-top: 10px;
}
.me {
width: 450px;
margin-right: 20px;
float: left;
}
.navbar {
padding: 1em;
background-color: #fff;
border-top: 1px solid #000;
border-bottom: 1px solid #000;
}
.navbar a {
background-color: #eee;
display: inline-block;
padding: 0.5em 1em;
border: 1px solid #999;
text-decoration: none;
color: #000;
}
.navbar a:hover {
background-color: #000;
color: #fff;
}
.navbar .selected {
background-color: #000;
color: #fff;
}
.byline {
padding: 5px;
border-top: 1px solid black;
overflow: auto;
}
.byline img {
float: left;
margin-right: 30px;
}
.byline p {
margin-top: 0;
}
article {
padding: 10px;
}
article > header {
text-align: center;
}
main {
min-height: 30em;
}
.author {
font-size: 15px;
font-style: italic;
}
.center {
text-align: center;
}
@media (max-width: 980px) {
body {
width: auto;
background-color: black;
}
.byline {
font-size: 10px;
}
.author {
font-size: 10px;
color: #aaa;
}
.me {
width: 80%;
display: block;
margin-bottom: 20px;
}
main {
background-color: #000;
margin-top: 15px;
color: white;
display: block;
border: 1px solid black;
}
.navbar a {
width: 90%;
text-align: left;
font-size: 18px;
background-color: #666;
display: block;
border: 1px solid #eee;
text-decoration: none;
color: white;
}
.site-title,
.site-slogan {
display: none;
}
.main-logo,
.site-header {
width: auto;
}
}
Also see: Tab Triggers