We use cookies on this site to enhance your user experience
By clicking the Accept button, you agree to us doing so. More info on our cookie policy
We use cookies on this site to enhance your user experience
By clicking the Accept button, you agree to us doing so. More info on our cookie policy
Published: Jul 29, 2025 by C.S. Rhymes
I created a free account for Codepen to provide a demo with my blog post about ‘Creating a custom toggle in TailwindCSS’ but it took me a little while to figure out how to use Tailwindcss with codepen. So, this is what I did to get it working.
Looking at the get started guide in Tailwindcss documentation, it states:
Use the Play CDN to try Tailwind right in the browser without any build step. The Play CDN is designed for development purposes only, and is not intended for production.
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
First I copied and pasted the section from the <head>
tags in the Tailwind into the HTML section of Codepen, but you shouldn’t do this.
I got a warning in Codepen saying the HTML section is only for content inside the body tags. So this needed to go somewhere else.
Instead of putting the above in the HTML section, you need to open the Pen settings, by clicking on the Settings
button with the big cog.
Once in the settings, click on the HTML section on the left, then find the Stuff for <head>
section and paste it in there.
Then click Save and close
.
Now you can start writing your HTML in the HTML section and adding the Tailwindcss utility classes. The page will refresh and display your styled content.
As the Tailwindcss documentation states, you can also customise your theme by adding a style tag with the type="text/tailwindcss"
attribute.
This seems to work in either the main HTML section or within the Stuff for <head>
section in the settings.
<style type="text/tailwindcss">
@theme {
--color-clifford: #da373d;
}
</style>
<p class="text-clifford">Test</p>
Photo by Sergei Gussev on StockSnap
Share
Latest Posts
When I launched my cozy mystery series, The Little-Astwick Mysteries, I decided to create a new website to promote it. But I made a few mistakes with SEO that have led to a few issues with Search Engine Optimisation (SEO). Here is how I fixed them.
I created a free account for Codepen to provide a demo with my blog post about ‘Creating a custom toggle in TailwindCSS’ but it took me a little while to figure out how to use Tailwindcss with codepen. So, this is what I did to get it working.
I’ve only just started using TailwindCSS, (I know late to the party huh), and I wanted to create a custom toggle switch that looked a bit nicer than a standard checkbox. This blog post goes through some of the thought processes and the tools that Tailwindcss v4 has out of the box that you can make use of.
Unlooked for Tales - a collection of short stories
By C.S. Rhymes
Free on Apple Books and Google Play Books
Nigel's Intranet Adventure
By C.S. Rhymes
From £0.99 or read for free on Kindle Unlimited!