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.
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<html>
<body>
<center>
<h1></h1>
<svg id="mySVG" width="640" height="640" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" stroke="black">
<defs>
<pattern id="rwp" width="64" height="64" patternUnits="userSpaceOnUse" patternTransform="rotate(0) scale(5)">
<g>
<path class="G1" d="M64,44L64,64L44,64C44,63.71 44.12,61.9 44.17,61.49L44.18,61.49C47.23,61.46 50.08,60.65 52.56,59.25C55.36,57.68 57.69,55.36 59.25,52.56C60.65,50.08 61.46,47.22 61.49,44.18C61.69,44.15 63.7,44 64,44"/>
<path class="G1" d="M64,0L64,20C63.7,20 61.9,19.88 61.49,19.83C61.46,16.78 60.65,13.92 59.25,11.44C57.68,8.64 55.36,6.32 52.56,4.75C50.08,3.35 47.23,2.54 44.18,2.51L44.17,2.51C44.16,2.45 44,0.3 44,0L64,0Z"/>
<path class="G1" d="M20,64.001L0,64.001L0,44.001C0.3,44.001 2.31,44.15 2.51,44.181C2.54,47.221 3.35,50.081 4.75,52.561C6.31,55.361 8.64,57.681 11.44,59.251C13.92,60.65 16.77,61.461 19.82,61.49L19.83,61.49C19.88,61.9 20,63.711 20,64.001"/>
<path class="G1" d="M20,0C20,0.253 19.84,2.45 19.83,2.51L19.82,2.51C16.77,2.54 13.92,3.35 11.44,4.75C8.64,6.32 6.32,8.64 4.75,11.44C3.35,13.92 2.54,16.78 2.51,19.83C2.1,19.88 0.3,20 0,20L0,0L20,0Z"/>
</g>
<g>
<path d="M48,64L32,64L20,64C20,52.962 11.038,44 0,44L0,20C11.038,20 20,11.038 20,0L44,0C44,11.038 52.962,20 64,20L64,44C53.005,44 44.07,52.892 44,63.871L48,64ZM32,11.979C43.05,11.979 52.021,20.95 52.021,32C52.021,43.05 43.05,52.021 32,52.021C20.95,52.021 11.979,43.05 11.979,32C11.979,20.95 20.95,11.979 32,11.979Z" class="G3"/>
</g>
<g>
<path class="G2" d="M59.25,52.56C57.69,55.36 55.36,57.68 52.56,59.25C52.006,57.287 50.073,54.389 48.248,52.098C48.195,52.031 46.77,50.33 46.21,49.76C45.65,49.21 44.92,48.57 44.11,47.92C44.32,47.76 38.77,44.01 36.75,43.44C38.32,40.64 40.64,38.32 43.44,36.75C44.01,38.77 46.03,41.78 47.9,44.09C47.88,44.12 49.77,46.23 49.79,46.25C50.36,46.8 51.85,48.13 51.9,48.1C54.22,49.96 57.23,51.99 59.25,52.56"/>
<path class="G2" d="M11.44,59.251C8.639,57.691 6.32,55.361 4.75,52.561C6.77,51.991 9.78,49.961 12.1,48.091C12.929,47.421 13.669,46.771 14.24,46.211C14.79,45.651 16.129,44.151 16.089,44.101C17.96,41.781 19.99,38.771 20.56,36.751C23.36,38.321 25.679,40.641 27.25,43.441C25.23,44.011 22.219,46.031 19.91,47.901C19.879,47.881 17.75,49.791 17.75,49.791C17.2,50.361 15.87,51.851 15.9,51.901C14.04,54.221 12.009,57.231 11.44,59.251"/>
<path class="G2" d="M52.56,4.751C55.361,6.311 57.68,8.641 59.25,11.441C57.23,12.011 54.22,14.041 51.9,15.911C51.071,16.581 50.331,17.231 49.76,17.791C49.21,18.351 47.871,19.851 47.911,19.901C46.04,22.221 44.01,25.231 43.44,27.251C40.64,25.681 38.321,23.361 36.75,20.561C38.77,19.991 41.781,17.971 44.09,16.101C44.121,16.121 44.121,16.101 44.111,16.091C44.93,15.421 45.64,14.801 46.21,14.251C46.21,14.251 48.13,12.151 48.1,12.101C49.96,9.781 51.991,6.771 52.56,4.751"/>
<path class="G2" d="M4.75,11.44C6.31,8.64 8.64,6.32 11.44,4.75C12.01,6.77 14.04,9.78 15.91,12.1C16.58,12.93 17.23,13.67 17.79,14.24C18.35,14.79 19.08,15.43 19.89,16.08C19.68,16.24 25.23,19.99 27.25,20.56C25.68,23.36 23.36,25.68 20.56,27.25C19.99,25.23 16.1,19.88 16.09,19.89C15.42,19.07 14.8,18.36 14.25,17.79C14.24,17.78 12.92,16.57 12.1,15.91C12.15,15.87 12.15,15.87 12.1,15.9C9.78,14.04 6.77,12.01 4.75,11.44"/>
</g>
<path class="G1" d="M52,32C52,32.3 51.83,34.51 51.83,34.51L51.82,34.51C48.77,34.54 45.92,35.35 43.44,36.75C40.64,38.32 38.32,40.64 36.75,43.44C35.35,45.92 34.54,48.78 34.51,51.83C34.1,51.88 32.3,52 32,52C31.7,52 29.9,51.88 29.49,51.83C29.46,48.78 28.65,45.92 27.25,43.44C25.68,40.64 23.36,38.32 20.56,36.75C18.08,35.35 15.23,34.54 12.18,34.51L12.17,34.51L12.17,34.48C12.12,34.08 12,32.3 12,32C12,31.71 12.12,29.9 12.17,29.49L12.18,29.49C15.23,29.46 18.08,28.65 20.56,27.25C23.36,25.68 25.69,23.36 27.25,20.56C28.65,18.08 29.46,15.22 29.49,12.18C29.69,12.15 31.7,12 32,12C32.3,12 34.31,12.15 34.51,12.18C34.54,15.22 35.35,18.08 36.75,20.56C38.31,23.36 40.64,25.68 43.44,27.25C45.92,28.65 48.77,29.46 51.82,29.49L51.83,29.49C51.88,29.9 52,31.71 52,32"/>
</pattern>
</defs>
<rect x="0" y="0" width="640" height="640" fill="darkgreen" stroke="none"/>
<rect x="0" y="0" width="640" height="640" fill="url(#rwp)" stroke="black" stroke-width="10"/>
</svg>
<div id="controller">
<h2>Playing with scale and rotate on the pattern</h2>
<label style="text-align:left;">Rotation in degree: <span id="lblRotation">0°</span></label>
<input id="myRotation" type="range" min="0" max="360" step="1" value="0" onchange="fChangeAngle()" oninput="fChangeAngle()"/>
<label style="text-align:left;">Scale factor: <span id="lblScale">5x</span></label>
<input id="myScale" type="range" min="1" max="10" step="0.5" value="5" onchange="fChangeAngle()" oninput="fChangeAngle()"/>
<label style="text-align:left;">Stroke: (<span id="btnStroke">on</span>)</label>
<input id="myStroke" type="range" min="0" max="1" step="1" value="1" onchange="fEnableStrokes()" oninput="fEnableStrokes()"/>
</div>
</center>
</body>
</html>
body{
background-color:#FC3;
padding:0px;
margin:0px;
font-family: Raleway, sans-serif;
}
h1{
font-weight: 200;
}
h2{
font-weight: 500;
}
.G1{
fill: #FCEA0D;
}
.G2{
fill: #DFDB00;
}
.G3{
fill: #B1DB00;
}
svg{
fill-rule: evenodd;
clip-rule: evenodd;
stroke-linejoin: round;
stroke-miterlimit: 1.41421;
stroke-width: 1;
}
#controller{
width: 580px;
height: 160px;
margin: 20px;
padding: 25px;
border: 5px solid black;
font-weight: 400;
}
label{
text-align: left;
}
#myRotation, #myScale{
width: 100%;
}
#myStroke{
width: 5%;
}
#lblRotation, #lblScale, #btnStroke{
color: darkgreen;
font-weight: 500;
}
.mylabel{
fill: darkgreen;
font-family: Raleway;
font-weight: 200;
font-size: 2em;
}
#inlineRotation, #inlineScale{
font-weight: 400;
}
function fChangeAngle() {
//reference slider values
var angle = document.getElementById('myRotation').value;
var scale = document.getElementById('myScale').value;
//create string as value for the patternTransform attribute
var myvalsp = "rotate("+ angle +") scale("+ scale +")";
//modify patternTransform attribute with rotate and scale function
document.getElementById("rwp").setAttribute("patternTransform", myvalsp);
//refresh label with current rotation angle and scale factor
document.getElementById("lblRotation").innerHTML = angle+"°";
document.getElementById("lblScale").innerHTML = scale+"x";
};
function fEnableStrokes(){
//reference slider values
var strokestate = document.getElementById('myStroke').value;
if (strokestate == 1) {
document.getElementById("btnStroke").innerHTML = "on";
document.getElementById("mySVG").setAttribute("stroke", "black");
} else{
document.getElementById("btnStroke").innerHTML = "off";
document.getElementById("mySVG").setAttribute("stroke", "none");
}
};
Also see: Tab Triggers