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 URL's 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 it's URL and the proper URL extention.
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.
<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>
<!--
Hello Camper!
For now, the test suite only works in Chrome! Please read the README below in the JS Editor before beginning. Feel free to delete this message once you have read it. Good luck and Happy Coding!
- The freeCodeCamp Team
-->
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;400;700&display=swap" rel="stylesheet">
<html>
<body>
<div class="container">
<nav id="navbar" class="navbar">
<header>
<p class="tc-header">CSS Functions</p>
<a href="#hsl()_Function" class="nav-link">hsl() Function</a>
<a href="#hsla()_Function" class="nav-link">hsla() Function</a>
<a href="#rgb()_Function" class="nav-link">rgb() Function</a>
<a href="#rgba()_Function" class="nav-link">rgba() Function</a>
<a href="#var()_Function" class="nav-link">var() Function</a>
</header>
</nav>
<main id="main-doc">
<section class="main-section" id="hsl()_Function">
<header>hsl() Function</header>
<p class="description">Definition and Usage</p>
<p>The hsl() function define colors using the Hue-saturation-lightness model (HSL).</p>
<p>HSL stands for hue, saturation, and lightness - and represents a cylindrical-coordinate representation of colors.</p>
<code>#p1 {background-color:hsl(120,100%,50%);} /* green */</code>
<!-- Start Table 1 -->
<p class="description">CSS Syntax</p>
<div class="tbl-flx">
<ul>
<div class="tbl-flx-left">
<li>hsl(hue, saturation, lightness)</li>
<li><span class="tc-span-1">Value</span></li>
<li><span class="tc-span-1">hue</span></li>
<li><span class="tc-span-1">saturation</span></li>
<li><span class="tc-span-1">lightness</span></li>
</div> <!-- Close tbl-flx-left -->
</ul>
<ul>
<div class="tbl-flx-right">
<li class="tbl-bs">.</li>
<li><span class="tc-span-1"></span> Description</li>
<li><span class="tc-span-1"></span>Defines a degree on the color wheel (from 0 to 360) - 0 (or 360) is red, 120 is green, 240 is blue</li>
<li><span class="tc-span-1"></span> Defines the saturation; 0% is a shade of gray and 100% is the full color (full saturation)</li>
<li><span class="tc-span-1"></span> Defines the lightness; 0% is black, 50% is normal, and 100% is white</li>
</div> <!-- Close tbl-flx-right -->
</ul>
</div> <!-- Close class="tbl-flx" -->
</section>
<section class="main-section" id="hsla()_Function">
<header>hsla() Function</header>
<p class="description">Definition and Usage</p>
<p>The hsla() function define colors using the Hue-saturation-lightness-alpha model (HSLA).</p>
<p>HSLA color values are an extension of HSL color values with an alpha channel - which specifies the opacity of the color.</p>
<code>#p4 {background-color:hsla(120,60%,70%,0.3);} /* pastel green */</code>
<!-- Start Table 2 -->
<p class="description">CSS Syntax</p>
<div class="tbl-flx">
<ul>
<div class="tbl-flx-left">
<li>hsla(hue, saturation, lightness, alpha)</li>
<li><span class="tc-span-1">Value</span></li>
<li><span class="tc-span-1">hue</span></li>
<li><span class="tc-span-1">saturation</span></li>
<li><span class="tc-span-1">lightness</span></li>
<li><span class="tc-span-1">alpha</span></li>
</div> <!-- Close tbl-flx-left -->
</ul>
<ul>
<div class="tbl-flx-right">
<li class="tbl-bs">.</li>
<li><span class="tc-span-1"></span>Description</li>
<li><span class="tc-span-1"></span>Defines a degree on the color wheel (from 0 to 360) - 0 (or 360) is red, 120 is green, 240 is blue</li>
<li><span class="tc-span-1"></span>Defines the saturation; 0% is a shade of gray and 100% is the full color (full saturation)</li>
<li><span class="tc-span-1"></span>Defines the lightness; 0% is black, 50% is normal, and 100% is white</li>
<li><span class="tc-span-1"></span>Defines the opacity as a number between 0.0 (fully transparent) and 1.0 (fully opaque)</li>
</div> <!-- Close tbl-flx-right -->
</ul>
</div> <!-- Close class="tbl-flx" Table 2 -->
</section>
<section class="main-section" id="rgb()_Function">
<header>rgb() Function</header>
<p class="description">Definition and Usage</p>
<p>The rgb() function define colors using the Red-green-blue (RGB) model.</p>
<p>An RGB color value is specified with: rgb(red, green, blue). Each parameter defines the intensity of that color and can be an integer between 0 and 255 or a percentage value (from 0% to 100%).</p>
<p>For example, the rgb(0,0,255) value is rendered as blue, because the blue parameter is set to its highest value (255) and the others are set to 0.</p>
<code>#p2 {background-color:rgb(0,255,0);} /* green */</code>
<!-- Start Table 3 -->
<p class="description">CSS Syntax</p>
<div class="tbl-flx">
<ul>
<div class="tbl-flx-left">
<li>rgb(red, green, blue)</li>
<li><span class="tc-span-1">Value</span></li>
<li><span class="tc-span-1">red</span></li>
<li><span class="tc-span-1">green</span></li>
<li><span class="tc-span-1">blue</span></li>
</div> <!-- Close tbl-flx-left -->
</ul>
<ul>
<div class="tbl-flx-right">
<li class="tbl-bs">.</li>
<li><span class="tc-span-1"></span>Description</li>
<li><span class="tc-span-1"></span>Defines the intensity of red as an integer between 0 and 255, or as a percentage value between 0% and 100%</li>
<li><span class="tc-span-1"></span> Defines the intensity of green as an integer between 0 and 255, or as a percentage value between 0% and 100%</li>
<li><span class="tc-span-1"></span> Defines the intensity of blue as an integer between 0 and 255, or as a percentage value between 0% and 100%</li>
</div> <!-- Close tbl-flx-right -->
</ul>
</div> <!-- Close class="tbl-flx" Table 3 -->
</section>
<section class="main-section" id="rgba()_Function">
<header>rgba() Function</header>
<p class="description">Definition and Usage</p>
<p>The rgba() function define colors using the Red-green-blue-alpha (RGBA) model.</p>
<p>RGBA color values are an extension of RGB color values with an alpha channel - which specifies the opacity of the color.</p>
<code>#p2 {background-color:rgba(0,255,0,0.3);} /* green with opacity */</code>
<!-- Start Table 4 -->
<p class="description">CSS Syntax</p>
<div class="tbl-flx">
<ul>
<div class="tbl-flx-left">
<li>rgba(red, green, blue, alpha)</li>
<li><span class="tc-span-1">Value</span></li>
<li><span class="tc-span-1">red</span></li>
<li><span class="tc-span-1">green</span></li>
<li><span class="tc-span-1">blue</span></li>
<li><span class="tc-span-1">alpha</span></li>
</div> <!-- Close tbl-flx-left -->
</ul>
<ul>
<div class="tbl-flx-right">
<li class="tbl-bs">.</li>
<li><span class="tc-span-1"></span>Description</li>
<li><span class="tc-span-1"></span>Defines the intensity of red as an integer between 0 and 255, or as a percentage value between 0% and 100%</li>
<li><span class="tc-span-1"></span>Defines the intensity of green as an integer between 0 and 255, or as a percentage value between 0% and 100%</li>
<li><span class="tc-span-1"></span>Defines the intensity of blue as an integer between 0 and 255, or as a percentage value between 0% and 100%</li>
<li><span class="tc-span-1"></span>Defines the opacity as a number between 0.0 (fully transparent) and 1.0 (fully opaque)</li>
</div> <!-- Close tbl-flx-right -->
</ul>
</div> <!-- Close class="tbl-flx" Table 4 -->
</section>
<section class="main-section" id="var()_Function">
<header>var() Function</header>
<p class="description">Definition and Usage</p>
<p>The var() function is used to insert the value of a custom property instead of any part of a value of another property.</p>
<code>:root {--main-bg-color: coral;}
<br>
#div1 {
background-color: var(--main-bg-color);
}
<br>
#div2 {
background-color: var(--main-bg-color);
}</code>
<!-- Start Table 5 -->
<p class="description">CSS Syntax</p>
<div class="tbl-flx">
<ul>
<div class="tbl-flx-left">
<li>var(custom-property-name, value)</li>
<li><span class="tc-span-1">Value</span></li>
<li><span class="tc-span-1">custom-property-name</span></li>
<li><span class="tc-span-1">value</span></li>
</div> <!-- Close tbl-flx-left -->
</ul>
<ul>
<div class="tbl-flx-right">
<li class="tbl-bs">.</li>
<li><span class="tc-span-1"></span>Description</li>
<li><span class="tc-span-1"></span>Required. The custom property's name (must start with two dashes)</li>
<li><span class="tc-span-1"></span>Optional. The fallback value (used if the custom property is invalid)</li>
</div> <!-- Close tbl-flx-right -->
</ul>
</div> <!-- Close class="tbl-flx" Table 5 -->
<!-- <div class="td-alt-color">
<ul>
<li>li-1</li>
<li>li-2</li>
<li>li-3</li>
<li>li-4</li>
<li>li-5</li>
</ul>
</div> -->
</section>
</main>
<footer id="footer">
<p>For full documentation visit <a href="https://www.w3schools.com/cssref/css_functions.asp" target="_blank"> w3schools.com</a> <img src="https://www.w3schools.com/favicon.ico" height="25px" id="logo"> </p>
</footer>
</div>
</body>
</html>
html {
scroll-behavior: smooth;
}
body {
background-color: whitesmoke;
font-family: 'Roboto', sans-serif;
margin: 0;
padding: 0;
}
div.container {
/* border: 1px solid orange; */
display: grid;
grid-template-columns: minmax(250px, auto) minmax(550px, 1fr);
grid-template-areas:
"nav-grid main-grid"
"footer footer";
grid-gap: 50px;
}
.tc-header {
border: 1px solid white;
background-color: whitesmoke;
border-radius: 5px;
box-shadow: 3px 3px 3px gray;
}
nav#navbar {
grid-area: nav-grid;
position: fixed;
}
nav#navbar a {
/* border: 1px solid black; */
display: flex;
padding: 5px;
margin: 10px 0;
text-decoration: none;
color: whitesmoke;
text-shadow: 1px 1px 1px black;
}
.navbar {
border: 1px solid white;
border-radius: 5px;
box-shadow: 3px 3px 3px gray;
background-color: #999;
padding: 5px;
text-align: center;
}
main#main-doc {
/* border: 1px solid; */
grid-area: main-grid;
}
#footer {
display: flex;
grid-area: footer;
justify-content: center;
text-shadow: 1px 1px 1px white;
}
#footer img {
box-shadow: 3px 3px 3px gray;
margin-bottom: -5px;
}
header {
/* color: red; */
font-size: 1.7rem;
font-weight: bold;
margin: 15px auto;
text-shadow: 1px 1px 1px #333;
}
code {
color: white;
text-shadow: 1px 1px 1px black;
background-color: #999;
display: block;
padding: 20px;
border: 1px solid white;
border-radius: 5px;
box-shadow: 3px 3px 3px gray;
}
.description {
font-size: 1.5em;
}
ul {
list-style: none;
padding-left: 0;
}
ul li.tbl-bs {
color: black;
}
.tbl-flx {
/* border: 2px solid yellow; */
display: flex;
padding: 0;
margin: 0;
}
.tbl-flx-left {
display: flex;
flex-direction: column;
white-space: nowrap;
border-top: 2px solid black;
border-left: 2px solid black;
border-bottom: 2px solid black;
}
.tbl-flx-right {
display: flex;
flex-direction: column;
/* overflow: scroll; */
white-space: nowrap;
border-top: 2px solid black;
border-right: 2px solid black;
border-bottom: 2px solid black;
}
.tc-span-1:nth-child(2) {
/* color: green; */
font-weight: bold;
font-style: normal;
padding-right: 40px;
}
.tbl-flx-left li:nth-child(2) {
/* color: green; */
font-style: initial !important;
}
.tc-span-1:first-child {
/* color: red; */
/* border: 1px solid blue; */
}
ul li {
text-shadow: 1px 1px 1px #333;
list-style-type: none;
text-shadow: none;
padding: 3px;
}
li:nth-child(odd) {
background-color: #999;
}
li:nth-child(even) {
background-color: white;
}
li:first-child {
color: whitesmoke;
background-color: black;
font-style: italic;
}
li:nth-child(2) {
font-weight: bold;
}
footer {
background-color: #999;
display: block;
padding: 20px;
border: 1px solid white;
border-radius: 5px;
/* box-shadow: -3px -3px 0px gray; */
}
@media screen and (max-width: 500px) {
div.container {
grid-template-columns: 1fr;
grid-template-areas:
"nav-grid"
"main-grid"
"footer";
grid-gap: 25px;
padding: 25px;
}
nav#navbar {
/* border: 1px solid blue; */
position: inherit;
/* display: flex; */
text-align: left;
}
#footer {
justify-content: left;
}
}
// !! IMPORTANT README:
// You may add additional external JS and CSS as needed to complete the project, however the current external resource MUST remain in place for the tests to work. BABEL must also be left in place.
/***********
INSTRUCTIONS:
- Select the project you would
like to complete from the dropdown
menu.
- Click the "RUN TESTS" button to
run the tests against the blank
pen.
- Click the "TESTS" button to see
the individual test cases.
(should all be failing at first)
- Start coding! As you fulfill each
test case, you will see them go
from red to green.
- As you start to build out your
project, when tests are failing,
you should get helpful errors
along the way!
************/
// PLEASE NOTE: Adding global style rules using the * selector, or by adding rules to body {..} or html {..}, or to all elements within body or html, i.e. h1 {..}, has the potential to pollute the test suite's CSS. Try adding: * { color: red }, for a quick example!
// Once you have read the above messages, you can delete all comments.
Also see: Tab Triggers