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.
<div class="container-fluid">
<div class="row">
<div class="col-xs-12">
<h1>Image name generator</h1>
</div>
</div>
<div class="row">
<div clas="col-xs-12">
<div class="chunk segment">
<label name="segment">Segment</label>
<select>
<option disabled selected>segment</option>
<option>med</option>
<option>phr</option>
<option>cor</option>
</select>
</div>
<div class="hyphen">
‐
</div>
<div class="chunk type">
<label>type</label>
<select class="type-select">
<option>ext</option>
<option>com</option>
<option>email</option>
<option>soc</option>
<option>int</option>
</select>
</div>
<div class="hyphen">
‐
</div>
<div class="chunk content">
<label>content</label>
<select class="empty" disabled>
</select>
<select class="ext" disabled>
<option>N/A</option>
</select>
<select class="com">
<option>ImageLarge</option>
<option>FeaturedStat</option>
<option>ImageCTASmall</option>
<option>ImageCTALarge</option>
<option>ImageCTAPrimary</option>
<option>TextCarousel</option>
<option>NowTrending</option>
<option>ImageTextRotator</option>
<option>CarouselContent</option>
<option>ImageGallery</option>
<option>ProductImage</option>
<option>TabbedRotator</option>
<option>Video</option>
<option>Search</option>
<option>Essential Insights</option>
<option>Expert</option>
<option>Category1Icon</option>
<option>Category2Featured</option>
<option>CategoryFeatured</option>
<option>HomepageBanner</option>
<option>CategoryMain</option>
</select>
<select class="email">
<option>banner</option>
<option>inline</option>
</select>
<select class="soc">
<option>tw</option>
<option>fb</option>
<option>li</option>
</select>
<select class="int">
<option>myCAH</option>
<option>myHR</option>
<option>Store</option>
</select>
</div>
<div class="hyphen">
‐
</div>
<div class="chunk descriptor">
<label>descriptive name</label>
<input placeholder="descriptive name">
</div>
<div class="hyphen">
‐
</div>
<div class="chunk campaign">
<label>campaign (if applicable)</label>
<input placeholder="Campaign name here">
</div>
<div class="hyphen">
‐
</div>
<div class="chunk dimensions">
<label>image dimensions</label>
<input class="width" placeholder="width"> x
<input class="height" placeholder="height">
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<label class="result-label">Your file name</label>
<input class="result">
</div>
</div>
</div>
body
font-family: Roboto
font-size: 18px
margin: 0
padding: 20px
color: #333333
h1
font-weight: 300
font-size: 2em
letter-spacing: -0.0325em
margin-left: -15px
label
display: block
font-size: .88em
select, input
font-size: .88em
font-weight: 300
padding: 8px 4px
width: 175px
max-width: 100%
border-radius: 4px
background: #E7E7E7
border: 0
select
width: 100px
.content select
width: 175px
.dimensions
input
width: 100px
.hyphen
display: inline-block
font-weight: 900
font-size: 2em
margin-top: 20px
vertical-align: bottom
.chunk
display: inline-block
vertical-align: top
select
display: block
text-align: center
.soc, .segment select
text-transform: uppercase
.result
width: 400px
max-width: 100%
margin-left: -15px
color: #E41F35
.result-label
margin-top: 2em
margin-left: -15px
$(document).ready(function() {
$('.content select').not('.empty').hide();
function selectContent(contentType) {
$('.content select').hide();
$(contentType).show();
}
function pushResult() {
var currentYear = (new Date()).getFullYear();
var currentYear = currentYear.toString().substr(2, 3) + "-";
var selected1 = $('.segment select').val();
var selected1 = selected1.toUpperCase();
var selected2 = $('.type-select').val();
var selected3 = "-" + $('.content select[class="'+selected2+'"]').val() + "-";
var selected4 = $(".descriptor input").val();
var selected5 = "-" + $(".campaign input").val() + "-";
if (selected5 == "--") {
selected5 = "";
}
var imgWidth = $('.width').val() + "x";
if (imgWidth == "x") {
imgWidth = "";
}
var imgHeight = $('.height').val();
console.log(selected3);
if (selected3 == "-N/A-") {
var selected3 = "-";
console.log(selected3);
var result = selected1 + currentYear + selected2 + selected3 + selected4 + selected5 + imgWidth + imgHeight;
$(".result").val(result);
} else if (selected3 == "-inline-") {
var selected3 = "-";
console.log(selected3);
var result = selected1 + currentYear + selected2 + selected3 + selected4 + selected5 + imgWidth + imgHeight;
$(".result").val(result);
} else {
var selected3 = "-" + $("." + selected2).val() + "-";
if (selected3 == "-tw-" || selected3 == "-fb-" || selected3 == "-li-") {
var selected3 = selected3.toUpperCase();
}
var result = selected1 + currentYear + selected2 + selected3 + selected4 + selected5 + imgWidth + imgHeight;
$(".result").val(result);
}
}
$('.type-select').change(function() {
var selected = $('.type-select').val();
selectContent("." + selected);
});
$('select').change(function() {pushResult();});
$('input').change(function() {pushResult();});
$(".result").click(function(){$(this).select();});
});
Also see: Tab Triggers