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.
<body class="min-h-screen " x-data="{ atTop: true, openModal: false }"
x-on:scroll.window="atTop = (window.pageYOffset > 100) ? false : true; "
x-on:keydown.escape=" openModal = openModal ? false : true">
<section class="fixed w-full p-6 z-10" x-bind:class="{ 'bg-white shadow-lg': !atTop }">
<div class="flex items-center w-full justify-between">
<div class="flex items-center">
<div class="hover:scale-110 text-blue-700 "
x-bind:class="{ 'text-blue-900': !atTop, 'text-blue-700': atTop}">
<svg class="h-8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M3 3h18v18H3zM21 9H3M21 15H3M12 3v18"/>
</svg>
</div>
<div class=" text-4xl ml-4 font-serif text-blue-700 "
x-bind:class="{ 'text-blue-900': !atTop, 'text-blue-700 scale-110': atTop}">SiteName
</div>
</div>
<div class="flex items-center">
<ul class="hidden md:flex flex items-center">
<li class="p-2 text-gray-700 uppercase mr-8" x-data="{ open: false }"><a
href="#">Services</a></li>
<li class="relative p-2 text-gray-700 uppercase mr-3" x-data="{ open: false }">
<button @click="open = true" style="text-transform: inherit" class="flex items-center">About
<svg class="h-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M6 9l6 6 6-6"/>
</svg>
</button>
<ul class="absolute mt-2 right-0 bg-whiteborder shadow-lg" x-show="open"
@click.away="open = false">
<li class="p-2 bg-gray-200 text-gray-700" x-data="{ open: false }"><a
href="#">Test</a></li>
</ul>
</li>
<li class="relative p-2 text-gray-700 uppercase mr-3" x-data="{ open: false }">
<button @click="open = true" style="text-transform: inherit" class="flex items-center">With Kids
<svg class="h-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M6 9l6 6 6-6"/>
</svg>
</button>
<ul class="absolute mt-2 right-0 bg-whiteborder shadow-lg" x-show="open"
@click.away="open = false">
<li class="p-2 bg-gray-200 text-gray-700" x-data="{ open: false }"><a
href="#">Child 1</a></li>
<li class="p-2 bg-gray-200 text-gray-700" x-data="{ open: false }"><a
href="#">Child 2</a></li>
</ul>
</li>
</ul>
<div class="" x-on:click="openModal = !openModal">
<svg class="h-8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<line x1="3" y1="12" x2="21" y2="12"></line>
<line x1="3" y1="6" x2="21" y2="6"></line>
<line x1="3" y1="18" x2="21" y2="18"></line>
</svg>
</div>
</div>
</div>
</section>
<section class="fixed w-full p-6 h-full z-10 hidden bg-indigo-200"
x-bind:class="{ 'hidden': !openModal }">
<div class="flex items-center w-full justify-between">
<div class="flex items-center">
<div class="text-indigo-900 ">
<svg class="h-8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M3 3h18v18H3zM21 9H3M21 15H3M12 3v18"/>
</svg>
</div>
<div class=" text-4xl ml-4 font-serif text-indigo-900 ">SiteName</div>
</div>
<div class="flex items-center">
<div class="" x-on:click="openModal = !openModal">
<svg class="h-8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>
</div>
</div>
</div>
</section>
<section class="py-64 bg-gray-300 ">
<div class=" ">
<div class="py-64 container mx-auto px-6">
<div class=" "><h2 class=" text-5xl text-green-600 ">Heading</h2></div>
<div class=" "></div>
</div>
</div>
</section>
<section class=" bg-no-repeat">
<div class="bg-white">
<div class="py-64 container mx-auto px-6">
<div class=" "><h1 class=" p-0 m-0 text-4xl font-serif ">New Heading</h1></div>
</div>
</div>
</section>
<section class="bg-gray-900 ">
<div class="px-6 py-64 ">
<div class="mx-auto max-w-3xl font-light text-indigo-100 text-2xl mb-4 font-serif "><p>"Lorem ipsum dolor sit
amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore etdolore magna aliqua. Ut enim
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquipex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eufugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officiadeserunt mollit anim id est laborum."</p></div>
<label class=" max-w-2xl mx-auto block text-green-200 font-bold ">source here</label></div>
</section>
<section class="px-6 py-16 overflow-x-hidden bg-gray-400">
<div class="container mx-auto p-6 mb-6"><h2 class=" font-serif text-3xl text-center "
>Lorem ipsum dolor sit amet</h2>
<div class="text-center " data-aos="flip-down"><p>Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodoconsequat.</p></div>
</div>
<div class="container flex flex-wrap w-full mx-auto px-2">
<div class="w-full lg:w-1/3 mb-6 ">
<div class="mx-2 h-full p-4 bg-indigo-200 shadow-lg">
<div class="text-indigo-300 ">
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z"></path>
<line x1="4" y1="22" x2="4" y2="15"></line>
</svg>
</div>
<h3 class=" text-2xl text-blue-800 font-bold ">Lorem ipsum dolor sit amet</h3>
<div class="font-thin "><p>Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua.Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
dolore magnaaliqua.</p></div>
</div>
</div>
<div class="w-full lg:w-1/3 mb-6 ">
<div class="h-full mx-2 p-4 bg-indigo-200 shadow-lg">
<div class="text-indigo-300 ">
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z"></path>
<line x1="4" y1="22" x2="4" y2="15"></line>
</svg>
</div>
<h3 class=" text-2xl text-blue-800 font-bold ">Lorem ipsum dolor sit amet</h3>
<div class="font-thin "><p>Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
dolore magnaaliqua.</p></div>
</div>
</div>
<div class="w-full lg:w-1/3 mb-6 ">
<div class="mx-2 h-full p-4 bg-indigo-200 shadow-lg">
<div class="text-indigo-300 ">
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z"></path>
<line x1="4" y1="22" x2="4" y2="15"></line>
</svg>
</div>
<h3 class=" text-2xl text-blue-800 font-bold ">Lorem ipsum dolor sit amet</h3>
<div class="font-thin "><p>Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
dolore magnaaliqua.</p></div>
</div>
</div>
</div>
</section>
<section class="py-32 px-6 text-white overflow-x-hidden bg-gray-600">
<div class="container max-w-3xl mx-auto">
<div class="text-green-100 mb-2 ">
<svg class="mx-auto" xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 24 24"
fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M22 17H2a3 3 0 0 0 3-3V9a7 7 0 0 1 14 0v5a3 3 0 0 0 3 3zm-8.27 4a2 2 0 0 1-3.46 0"></path>
</svg>
</div>
<h2 class=" font-serif text-3xl text-center leading-tight mb-4 "
>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore etdolore magna aliqua.</h2>
<div class="text-center font-light text-lg mb-4 " data-aos="flip-right"
><p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodoconsequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
eu fugiat nullapariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit animid est laborum.</p></div>
<ul class="flex flex-wrap justify-center" data-aos="fade-down"
>
<li class="uppercase m-4 p-4 rounded-full hover:bg-white hover:text-blue-600 font-bold border-2"
x-data="{ open: false }"><a href="#">Duis aute irure dolor</a></li>
<li class="uppercase m-4 p-4 rounded-full hover:bg-white hover:text-blue-600 font-bold border-2"
x-data="{ open: false }"><a href="#">Excepteur</a></li>
</ul>
</div>
</section>
</body>
Also see: Tab Triggers