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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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.
/*
* Function to dynamically insert menu items into the Canvas left column
* navigation area.
*
* @param string linkText
* The text that will be visible
* @param string linkHref
* The URL that the link should point to. Note, that if this link is
* intended to trigger a modal window, this paramter will be ignored.
* You can't have a modal triggerd by an actual URL.
* @param string icon
* A valid icon name from the Canvas icon font.
* @see https://champlain.instructure.com/styleguide#icons
* @param string image
* A valid HTML fragment representing an image or SVG icon.
* These should be sized around 50x35.
* @param bool newWindow
* True or false, should this link open in a new window.
* Note, that if this link should be a modal, this parameter will
* be ignored.
* @param bool isModal
* True or false, should this link trigger a modal dialog.
* Note that we are relying the jQuery UI Dialog provided by Canvas.
* You will need to provide styling in your CSS to match your brand.
* @see https://jqueryui.com/dialog/
* @param string modalContent
* This content for the modal dialog. This should be valid HTML.
* @param object modalOptions
* An object of options that are available to the jQuery UI Dialog.
* @see https://api.jqueryui.com/dialog/#options
*
*/
function ccAddMenuItem (linkText, linkHref, icon, image, newWindow, isModal, modalContent, modalOptions) {
if($('#menu').length){
var iconHtml = '',
itemHtml,
linkId = linkText.split(' ').join('_'), // Generate the tail end of a unique ID for the element
modalContentId = 'cc-modal-'+linkId, // generate an ID for the modal content
menuLinkOpen, // Holds the markup that will go in the menu
linkHref = isModal ? '#' : linkHref, // If this is going to be a modal, it can't link to a page
modalOptions = modalOptions ? modalOptions : {}, // Check for modalOptions so we can merge them with defaults
imageSrc = !image ? false : true;
// If we are opening this in a new window, and it's not a modal
// our link has to have target="_blank"
if(newWindow && !isModal){
menuLinkOpen = ' <a id="global_nav_' + linkId + '" href="' + linkHref + '" class="ic-app-header__menu-list-link" target="_blank">';
} else{
menuLinkOpen = ' <a id="global_nav_' + linkId + '" href="' + linkHref + '" class="ic-app-header__menu-list-link">';
}
// If icon and image are supplied don't use either, we shouldn't make the decision.
// The caller should be smart enough not to pass both.
if (icon !== '' && !imageSrc) {
iconHtml = '<i class="' + icon + ' cc-icon"></i> ';
}
if(imageSrc !== false && icon == ''){
iconHtml = '<span class="cc-menu-image">' + image + '</span>';
}
itemHtml = '<li class="ic-app-header__menu-list-item">' +
menuLinkOpen +
iconHtml + '<div class="menu-item__text">' + linkText + '</div>' +
' </a>' +
'</li>';
$('#menu').append(itemHtml);
// If our menu item made it, and we are adding modal support
// trigger modal support
if(isModal && $('#global_nav_'+linkId).length){
var modalDefaults = {
'title' : 'Menu',
'resizable' : false,
'width' : 400
};
var modalSettings = $.extend({},modalDefaults,modalOptions);
// Wrapp the content we received into a correctly styled and ID div
var modalDiv = '<div id="' + modalContentId + '" style="display:none;" class="cc-help-dialog">' + modalContent + '</div>';
$('body').append(modalDiv);
$('#global_nav_'+linkId).on('click',function(){
$('#'+modalContentId).dialog(modalSettings);
});
}
}
}
function ccAddLibraryLinks(){
var libraryHelpMenu = ' <ul class="cc-help-dialog-options">'+
' <li><a href="http://www.champlain.edu/academics/library/find-books-articles-and-more/find-articles" target="_blank"><span class="name ellipsis text">Research databases</span></a></li>' +
' <li><a href="http://www.champlain.edu/academics/library/find-books-articles-and-more/find-books-and-ebooks" target="_blank"><span class="name ellipsis text">Find books and eBooks</span></a></li>' +
' <li><a href="http://www.champlain.edu/academics/library/get-help/ask-us" target="_blank"><span class="name ellipsis text">Ask a librarian</span></a></li>' +
' <li><a href="http://subjectguides.champlain.edu/content.php?pid=292793&sid=2403742" target="_blank"><span class="name ellipsis text">Get citation help</span></a></li>' +
' <li><a href="http://www.champlain.edu/academics/library" target="_blank"><span class="name ellipsis text">Library website</span></a></li>' +
' </ul>';
var modalOptions = {
'title' : 'Library Resources',
'resizable' : false,
'width' : 400
};
var svgIcon = '<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="45px" height="30px" x="0px" y="0px" viewBox="179.2 189.3 389.4 358.5" enable-background="new 179.2 189.3 389.4 358.5" xml:space="preserve"><path fill="#FFFFFF" d="M247.4,189.3c81.6,19.2,118.7,81.2,118.7,81.2v277.2c-41.7-59.9-118.7-84.3-118.7-84.3V461C247.4,461,247.5,189,247.4,189.3z"></path><path fill="#FFFFFF" d="M260.1,530.2c0,0-34.6-17.5-80.8-10.3V247.6h11.4v258.8C190.6,506.2,240.4,505.7,260.1,530.2z"></path><path fill="#FFFFFF" d="M306.8,521.3L306.8,521.3c-18-25.7-75-45.7-75-45.7V219.9l-23.6-9.2V489c0,0,24.3,3,36.4,6.4C286.5,507.2,306.8,521.3,306.8,521.3z"></path><path fill="#FFFFFF" d="M500.5,189.3c-81,25.2-118.7,81.2-118.7,81.2v277.2c41.7-59.9,118.7-84.3,118.7-84.3S500.5,190,500.5,189.3z"></path><path fill="#FFFFFF" d="M487.9,530.2c0,0,34.6-17.5,80.8-10.3V247.6h-11.4v258.8C557.3,506.2,507.6,505.7,487.9,530.2z"></path><path fill="#FFFFFF" d="M441.1,521.3L441.1,521.3c18-25.7,75-45.7,75-45.7V219.9l23.6-9.2V489c0,0-24.3,3-36.4,6.4C461.4,507.2,441.1,521.3,441.1,521.3z"></path></svg>';
ccAddMenuItem('Library','#','',svgIcon,false,true,libraryHelpMenu,modalOptions);
}
Also see: Tab Triggers