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.
<textarea>
<h1>Visiting Norway</h1>
<p><strong><img style="float: right;" src="https://images.pexels.com/photos/1559825/pexels-photo-1559825.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" alt="Town" width="300" height="375"></strong>Norway, officially the Kingdom of Norway, is a <a href="https://en.wikipedia.org/wiki/Nordic_countries">Nordic country</a> in Northern Europe, the mainland territory of which comprises the western and northernmost portion of the Scandinavian Peninsula.</p>
<p>The remote Arctic island of Jan Mayen and the archipelago of Svalbard also form part of Norway. Bouvet Island, located in the <a href="https://en.wikipedia.org/wiki/Subantarctic">Subantarctic</a>, is a dependency of Norway; it also lays claims to the Antarctic territories of Peter I Island and Queen Maud Land. The capital and largest city in Norway is <a href="https://en.wikipedia.org/wiki/Oslo">Oslo</a>.<strong><br></strong></p>
<p>Listen to Norway's royal anthem on Spotify:</p>
<div style="left: 0px; width: 100%; height: 152px; position: relative; max-width: 650px;" data-ephox-embed-iri="https://open.spotify.com/track/6SPocux2pBpFp3lshAOek1?si=907d52cf2af94efc"><iframe style="top: 0; left: 0; width: 100%; height: 100%; position: absolute; border: 0;" src="https://open.spotify.com/embed/track/6SPocux2pBpFp3lshAOek1?utm_source=oembed" allow="clipboard-write; encrypted-media; fullscreen; picture-in-picture;" allowfullscreen="allowfullscreen"></iframe></div>
<h2>Geography</h2>
<div class="related-content">
<h3>Related content</h3>
<p><strong>Lorem ipsum</strong> dolor sit amet...</p>
</div>
<p>Norway has a total area of 385,207 square kilometres (148,729 sq mi) and had a population of 5,425,270 in January 2022. The country shares a long eastern border with Sweden at a length of 1,619 km (1,006 mi). It is bordered by Finland and Russia to the northeast and the Skagerrak strait to the south, on the other side of which are Denmark and the United Kingdom.</p>
<p>Norway has an extensive coastline, facing the North Atlantic Ocean and the Barents Sea. The maritime influence dominates Norway's climate, with mild lowland temperatures on the sea coasts; the interior, while colder, is also significantly milder than areas elsewhere in the world on such northerly latitudes. Even during polar night in the north, temperatures above freezing are commonplace on the coastline. The maritime influence brings high rainfall and snowfall to some areas of the country.</p>
<h2>Norway 3-day itinerary</h2>
<p>If you're in Norway for a long weekend or just a short trip, here's our recommendation:</p>
<table style="border-collapse: collapse; border-width: 1px;" border="1">
<thead>
<tr>
<td style="width: 12.9794%; border-width: 1px;"> </td>
<td style="width: 44.5428%; border-width: 1px;"><strong>Location</strong></td>
<td style="width: 42.4779%; border-width: 1px;"><strong>Activity</strong></td>
</tr>
</thead>
<tbody>
<tr>
<td style="width: 12.9794%; border-width: 1px;"><strong>Day 1</strong></td>
<td style="width: 44.5428%; border-width: 1px;">Flåm Mountain Railway and Flåm village</td>
<td style="width: 42.4779%; border-width: 1px;">Tellus est malesuada </td>
</tr>
<tr>
<td style="width: 12.9794%; border-width: 1px;"><strong>Day 2</strong></td>
<td style="width: 44.5428%; border-width: 1px;">UNESCO-listed Nærøyfjord and Voss village</td>
<td style="width: 42.4779%; border-width: 1px;">Vivamus pretium ornare est</td>
</tr>
<tr>
<td style="width: 12.9794%; border-width: 1px;"><strong>Day 3</strong></td>
<td style="width: 44.5428%; border-width: 1px;">Leaving Voss</td>
<td style="width: 42.4779%; border-width: 1px;">Amet, consectetuer adipiscing</td>
</tr>
</tbody>
</table>
<h2>Where to book your travel</h2>
<ol>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
</ol>
<blockquote>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.</p>
</blockquote>
<h3>Staying healthy</h3>
<ul>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
</ul>
<p><em>Featuring <a href="https://en.wikipedia.org/wiki/Norway">content from Wikipedia</a></em></p>
</textarea>
tinymce.init({
// Select the element(s) to add TinyMCE to using any valid CSS selector
selector: "textarea",
// Tip - To keep TinyMCE lean, only include the plugins you need.
plugins:
"a11ychecker advcode advlist advtable anchor autocorrect autolink autosave editimage fullscreen image link linkchecker lists media mediaembed pageembed powerpaste searchreplace table template tinymcespellchecker typography visualblocks wordcount",
// Configure the toolbar so it fits your app. There are many
// different configuration options available:
// https://www.tiny.cloud/docs/tinymce/6/toolbar-configuration-options/
toolbar:
"undo redo | styles | bold italic underline strikethrough | align | table link image media pageembed | bullist numlist outdent indent | spellcheckdialog a11ycheck typography code | fullscreen",
// Specify the height of the editor, including toolbars and the statusbar.
// https://www.tiny.cloud/docs/tinymce/6/customize-ui/#changing-editor-height-and-width
height: 540,
// Configure the style menu and define available formats
// Here, we have defined a medium sized image format as an example.
// There is a lot more you can do with formats:
// https://www.tiny.cloud/docs/tinymce/6/filter-content/
style_formats: [
{ title: "Heading 1", block: "h1" },
{ title: "Heading 2", block: "h2" },
{ title: "Paragraph", block: "p" },
{ title: "Blockquote", block: "blockquote" },
{ title: "Image formats" },
{ title: "Medium", selector: "img", classes: "medium" }
],
// Use font_css to load custom fonts from an external source
// https://www.tiny.cloud/docs/tinymce/6/add-css-options/#font_css
font_css: [
"https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,500;1,400&display=swap"
], // URLs containing commas and such have to be wrapped in an array to work
// The following css will be injected into the editor, extending
// the default styles.
// In a real world scenario, it's recommended to use the content_css
// option to load a separate CSS file. This makes editing easier too.
// https://www.tiny.cloud/docs/tinymce/6/add-css-options/
content_style: `
body {
font-family: 'Roboto', serif;
color: #222;
}
img {
height: auto;
margin: auto;
padding: 10px;
display: block;
}
img.medium {
max-width: 25%;
}
a {
color:#116B59;
}
.related-content {
padding:0 10px;
margin: 0 0 15px 15px;
background:#eee;
width:200px;
float:right;
}
`,
// TinyMCE offers a wide range of options to control what classes, styles
// and attributes are allowed in the content. All other classes will be
// filtered out.
// https://www.tiny.cloud/docs/tinymce/6/content-filtering/#valid_classes
valid_classes: {
img: "medium",
div: "related-content"
},
// Enable image fig captions
// https://www.tiny.cloud/docs/tinymce/6/image/#image_caption
image_caption: true,
// Advanced Code Editor lets power users edit the editor's underlying HTML in real time,
// with indents and color coding. Enable inline view for a more seamless code editing
// experience.
// https://www.tiny.cloud/docs/tinymce/6/advcode/
advcode_inline: true,
// Templates is useful for when users need to insert repeatable content,
// for example a related content block.
// https://www.tiny.cloud/docs/tinymce/6/template/
templates: [
{
title: "Related content",
description: "This template inserts a related content block",
content:
'<div class="related-content"><h3>Related content</h3><p><strong>Lorem ipsum</strong> dolor sit amet...</p></div>'
}
],
});
Also see: Tab Triggers