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.
<h1 class="ui center aligned yellow header">Semantic UI Grid</h1>
<div class="ui basic center aligned segment">
<div class="ui horizontal divider"> <!-- .horizontal class is mandatory here -->
<div class="ui big buttons custom_toggle">
<button class="ui inverted active blue button" id="fixed">Fixed</button>
<div class="or"></div>
<button class="ui inverted blue button" id="fluid">Fluid</button>
</div>
</div>
</div>
<div class="ui hidden divider"></div>
<div class="ui center aligned grid container">
<h2>Basic 16</h2>
<div class="row"> <!-- .row element is not mandatory, .column is enough for grid to work -->
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
</div>
<h2>16/5 || 4x8x4</h2>
<div class="five column row">
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
</div>
<div class="row">
<div class="four wide column">
<p><span>Four</span></p>
</div>
<div class="eight wide column">
<p><span>Eight</span></p>
</div>
<div class="four wide column">
<p><span>Four</span></p>
</div>
</div>
<h2>Relaxed 4x8x4</h2>
<div class="relaxed row">
<div class="four wide column">
<p><span>Four</span></p>
</div>
<div class="eight wide column">
<p><span>Eight</span></p>
</div>
<div class="four wide column">
<p><span>Four</span></p>
</div>
</div>
<h2>Floated</h2>
<div class="five column row">
<div class="left floated column">
<p><span>Left</span></p>
</div>
<div class="right floated column">
<p><span>Right</span></p>
</div>
</div>
</div>
<div class="ui center aligned equal width grid container">
<h2>Equal width</h2>
<div class="equal width row">
<div class="column"><p><span>=</span></p></div>
<div class="column"><p><span>=</span></p></div>
<div class="column"><p><span>=</span></p></div>
</div>
<div class="equal width row">
<div class="column"><p><span>=</span></p></div>
<div class="column"><p><span>=</span></p></div>
</div>
</div>
<div class="ui center aligned grid container">
<div class="ui hidden divider"></div>
<h2>Celled</h2>
<div class="ui hidden divider"></div>
</div>
<div class="ui three column center aligned celled grid container">
<div class="row">
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
</div>
<div class="row">
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
</div>
</div>
<div class="ui center aligned grid container">
<div class="ui hidden divider"></div>
<h2>Internally Celled</h2>
<div class="ui hidden divider"></div>
</div>
<div class="ui three column center aligned internally celled grid container">
<div class="row">
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
</div>
<div class="row">
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
</div>
</div>
<div class="ui center aligned grid container">
<div class="ui hidden divider"></div>
<h2>Divided</h2>
<div class="ui hidden divider"></div>
</div>
<div class="ui three column center aligned divided grid container">
<div class="row">
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
</div>
<div class="row">
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
</div>
</div>
<div class="ui center aligned grid container">
<div class="ui hidden divider"></div>
<h2>Vertically Divided</h2>
<div class="ui hidden divider"></div>
</div>
<div class="ui three column center aligned vertically divided grid container">
<div class="row">
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
</div>
<div class="row">
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
</div>
</div>
<div class="ui center aligned grid container">
<div class="ui hidden divider"></div>
<h2>Nested</h2>
<div class="ui hidden divider"></div>
</div>
<div class="ui two column center aligned grid container">
<div class="column">
<div class="ui three column grid" id="nested_1">
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
</div>
</div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column">
<div class="ui grid" id="nested_2">
<div class="four wide column"><p></p></div>
<div class="twelve wide column">
<div class="ui equal width grid" id="nested_3">
<div class="column"><p></p></div>
<div class="column"><p></p></div>
</div>
</div>
</div>
</div>
<div class="ui hidden divider"></div>
</div>
<div class="ui hidden divider"></div>
<div class="ui equal width center aligned grid container" id="color_vars">
<h2>Color variations</h2>
<div class="row">
<div class="red column"><p></p></div>
<div class="orange column"><p></p></div>
<div class="yellow column"><p></p></div>
<div class="olive column"><p></p></div>
<div class="green column"><p></p></div>
<div class="teal column"><p></p></div>
<div class="blue column"><p></p></div>
<div class="violet column"><p></p></div>
<div class="purple column"><p></p></div>
<div class="pink column"><p></p></div>
<div class="brown column"><p></p></div>
<div class="grey column"><p></p></div>
<div class="black column"><p></p></div>
</div>
</div>
<div class="ui center aligned grid container">
<div class="ui hidden divider"></div>
<h2>Stackable (mobile)</h2>
<div class="ui hidden divider"></div>
</div>
<div class="ui stackable four column center aligned grid container">
<div class="row">
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
<div class="column"><p></p></div>
</div>
</div>
<div class="ui center aligned grid container">
<div class="ui hidden divider"></div>
<h2>Reverse order (mobile)</h2>
<div class="ui hidden divider"></div>
</div>
<div class="ui mobile reversed four column center aligned grid container">
<div class="row">
<div class="column"><p><span>1</span></p></div>
<div class="column"><p><span>2</span></p></div>
<div class="column"><p><span>3</span></p></div>
<div class="column"><p><span>4</span></p></div>
</div>
</div>
<div class="ui center aligned grid container">
<div class="ui hidden divider"></div>
<h2>Doubling column width (mobile)</h2>
<div class="ui hidden divider"></div>
</div>
<div class="ui center aligned grid container">
<div class="doubling eight column row" id="db_1">
<div class="column"><p><span>1</span></p></div>
<div class="column"><p><span>2</span></p></div>
<div class="column"><p><span>3</span></p></div>
<div class="column"><p><span>4</span></p></div>
<div class="column"><p><span>5</span></p></div>
<div class="column"><p><span>6</span></p></div>
<div class="column"><p><span>7</span></p></div>
<div class="column"><p><span>8</span></p></div>
</div>
<div class="doubling six column row" id="db_2">
<div class="column"><p><span>1</span></p></div>
<div class="column"><p><span>2</span></p></div>
<div class="column"><p><span>3</span></p></div>
<div class="column"><p><span>4</span></p></div>
<div class="column"><p><span>5</span></p></div>
<div class="column"><p><span>6</span></p></div>
</div>
<div class="doubling four column row" id="db_3">
<div class="column"><p><span>1</span></p></div>
<div class="column"><p><span>2</span></p></div>
<div class="column"><p><span>3</span></p></div>
<div class="column"><p><span>4</span></p></div>
</div>
</div>
<div class="ui center aligned grid container">
<div class="ui hidden divider"></div>
<h2>Custom visibility (mobile)</h2>
<div class="ui hidden divider"></div>
</div>
<div class="ui center aligned grid container">
<div class="widescreen only row">
<div class="column"><p><span>Widescreen</span></p></div>
</div>
<div class="large screen only row">
<div class="column"><p><span>Large Screen</span></p></div>
</div>
<div class="computer only row">
<div class="column"><p><span>Computer</span></p></div>
</div>
<div class="tablet computer only row">
<div class="column"><p><span>Tablet & Computer</span></p></div>
</div>
<div class="two column tablet only row">
<div class="column"><p><span>Tablet</span></p></div>
<div class="column"><p><span>Tablet</span></p></div>
</div>
<div class="three column mobile only row">
<div class="column"><p><span>Mobile</span></p></div>
<div class="column"><p><span>Mobile</span></p></div>
<div class="column"><p><span>Mobile</span></p></div>
</div>
<div class="three wide mobile six wide tablet twelve wide computer column sixteen wide widescreen column"><p><span>Different width based on screen size</span></p></div>
</div>
<div class="ui divider"></div>
p {
align-content: center;
background-color: @purple;
color: #fff;
display: flex;
flex-direction: column;
justify-content: center;
min-height: 6em;
span {
opacity: 0.4;
text-align: center;
}
}
// Nested grid visualization
#nested_1,
#nested_2 {
background-color: rgba(96, 112, 175, .2);
border: 3px dashed @purple;
p {
background-color: @yellow;
}
}
#nested_3 {
background-color: rgba(242, 182, 50, .3);
border: 3px dashed @yellow;
p {
background-color: @white;
}
}
// Color variations grid visualization
#color_vars {
p {
background-color: @black;
opacity: 0.1;
}
}
// Doubling grid visualization
#db_1 {
p {
background-color: #db2828;
}
}
#db_2 {
p {
background-color: #fbbd08;
}
}
#db_3 {
p {
background-color: #21ba45;
}
}
// Semantic UI theme mod styles
.ui {
.buttons {
.or { // Buttons sepsarator
text-transform: none;
&:before {
background-color: @purple-dark;
color: @white;
}
}
}
// Override division color to make it visible on dark background
&.divided {
&.grid {
&:not([class*="vertically divided"]) {
> .row {
> .column {
box-shadow: -1px 0 0 0 #d4d4d4;
}
}
}
}
}
&[class*="vertically divided"] {
&.grid {
> .row {
&:before {
box-shadow: 0 -1px 0 0 rgba(212, 212, 212, 1.0);
}
}
}
}
}
$('.ui.custom_toggle.buttons .button').click(function(){
$(this).addClass('active').siblings().removeClass('active')
});
$('#fixed').on('click', function(){
$('.grid').addClass('container');
});
$('#fluid').on('click', function(){
$('.grid').removeClass('container');
});
Also see: Tab Triggers