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.
<!--
design borrowed from
https://www.swissted.com/
-->
<div class="container">
<article id="poster" itemscope="" itemtype="http://schema.org/MusicEvent" data-display="grid">
<!--H1 band name is visible when not using grid layout. To achieve letter spacing on grid, use vanilla js to retrieve letters separated by " " from content="". Each letter is wrapped into individual html element (which is positioned on the grid). Maybe it could be done with svg shapes (Approach <use>: define somewhere in document, later assign grid cell = not working). Precisely placing text items on grid is problematic because of the line-height - would be great if could align-text:bottom /top -->
<h1 itemprop="performer" itemscope="" itemtype="http://schema.org/Person"><a id="venueBand" content="t h c u r e" href="https://en.wikipedia.org/wiki/The_Cure" itemprop="name">the cure</a></h1>
<h2 itemprop="performer" itemscope="" itemtype="http://schema.org/Person">with special guests<br/>
<a href="https://en.wikipedia.org/wiki/Joy_Division" itemprop="name">joy divison<a> & <a href="" itemprop="name">back to zero</a></h2>
<div class="venuePlace">
<time itemprop="startDate" content="1979-06-16" datetime="1979-06-16">saturday, june 16 1979</time>
<p itemprop="location" itemscope="" itemtype="http://schema.org/MusicVenue">live at <a href="#" itemprop="name">cantenbury odeon</a></p>
</div>
<p itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">tickets:<br/>
<meta itemprop="priceCurrency" content="GB">£</meta><span itemprop="price">1.25</span>
<span>advance / </span>
<meta itemprop="priceCurrency" content="GB">£</meta><span itemprop="price">2.50</span>
<span>door</span>
</p>
<footer id="footer" itemprop="organizer" itemscope="" itemtype="http://schema.org/organizer">presented by <a itemprop="name">university of kent<br/> catenbury students' union</a></footer>
</article>
</div>
@function pxToEm ($size) {
@return $size / 16 * 1em;
}
$gray: #839098;
$white: #dfe2d7;
$black: #000113;
//General page style
* {
box-sizing: border-box
}
html {
font-size: 62.5%;
color: $white;
background: $white;
}
body {
font-family: Arial, sans-serif;
font-size: 1.6em;
font-size: 1.6rem;
line-height: 1.3;
}
p {
margin: 0;
padding: 0;
}
.container {
width: 100%;
background-color: $black;
max-width: pxToEm(716);//IE8
max-width: 71.6rem;
padding: 1em;
margin: 0 auto;
height: (1008/716 * 100%);
}
.venuePlace,
footer {
text-align: right;
}
aside{
display: none;
}
h1 {
font-size: 20em; //IE8
font-size: 20vmin;
line-height: 1;
margin-top: 0;
font-weight: bold;
}
//Small screen and non-grid layout
@media screen and (max-width: pxToEm(716)) {
article > * {
margin-bottom: 2vh
}
}
a {
text-decoration: none;
color: inherit;
transition: background 0.2s linear, color 0.2s linear;
&:hover {
background: #fff;
color: $black;
}
}
article {
padding: 2rem;
}
h2 {
margin-top: 0;
font-size: 1.6rem;
text-align: right;
color: $gray;
}
//Grid layout
@media screen and (min-width: pxToEm(716)) {
@supports (display: grid) {
.container {
height: 100.8rem;
}
/*hide visually, but leave for screen reader */
h1 {
position:absolute;
left:-10000px;
top:auto;
width:1px;
height:1px;
overflow:hidden;
}
h2 {
margin: 0;
grid-column-start: 3;
grid-row-start: 2;
align-self: end;
grid-column-end: span 4;
}
article[data-display="grid"] {
display: grid;
grid-template-columns: 25% 25% 25% 25%;
grid-row-gap: 4vh;
}
[itemprop="offers"] {
grid-column-start: 1;
grid-column-end: span 2;
grid-row-start: 3;
margin-top: pxToEm(45);
align-self: baseline;
}
[itemprop="location"] {
align-self: end;
}
.venuePlace {
grid-column-start: 3;
grid-column-end: span 2;
grid-row-start: 1;
align-self: end;
grid-column-end: span 4;
}
footer {
grid-column-start: 3;
grid-row-start: 2;
align-self: start;
grid-column-end: span 4;
margin-top: pxToEm(40);
}
#poster {
height: 100%; //of parent, to preserve original aspect ratio
padding-top: 0;
aside {
display: block;
font-size: pxToEm(280);
line-height: 0.7;
font-weight: bold;
}
& aside:nth-of-type(1) {
grid-column-start: 1;
grid-row-start: 4;
color: $gray;
margin-left: 8px;
}
& aside:nth-of-type(2) {
grid-column-start: 2;
grid-row-start: 4;
color: $gray;
margin-left: 20%;
transform: translateX(50%);
}
& aside:nth-of-type(3) {
grid-column-start: 1;
grid-row-start: 1;
}
& aside:nth-of-type(4) {
grid-column-start: 2;
grid-row-start: 2;
}
& aside:nth-of-type(5) {
grid-column-start: 3;
grid-row-start: 3;
transform: translateX(50%);
}
& aside:nth-of-type(6) {
grid-column-start: 4;
grid-row-start: 4;
text-align: right;
}
}
}
}
// Progressive enhancement: if js & modern browser > IE10, then add js, otherwise do nothing
if ('visibilityState' in document) {
document.addEventListener("DOMContentLoaded", function () {
var article = document.getElementById('venueBand'),
poster = document.getElementById("poster"),
text = article.getAttribute("content"),
textArray = text.split(" "),
length = textArray.length;
for (var i = 0; i < length; i++) {
var char = textArray[i]
var element = document.createElement("aside");
element.append(char);
poster.append(element);
}
})
}
Also see: Tab Triggers