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.
<!-- title -->
<div class="p-24 bg-green-900 flex flex-col justify-center items-center">
<h2 class="pb-10 font-bold text-6xl text-green-200 text-center">Alerts with Tailwind CSS</h2>
</div>
<!-- simple alerts -->
<div class="p-24 bg-green-500 flex flex-col justify-center items-center space-y-5">
<h3 class="pb-10 font-bold text-4xl text-green-900 text-center">Simple Alerts</h3>
<div class="w-full p-5 rounded-lg border border-blue-400 bg-blue-300 text-blue-900">Primary Alert</div>
<div class="w-full p-5 rounded-lg border border-gray-500 bg-gray-400 text-gray-900">Secondary Alert</div>
<div class="w-full p-5 rounded-lg border border-green-400 bg-green-300 text-green-900">Success Alert</div>
<div class="w-full p-5 rounded-lg border border-red-400 bg-red-300 text-red-900">Danger Alert</div>
<div class="w-full p-5 rounded-lg border border-yellow-400 bg-yellow-300 text-yellow-900">Warning Alert</div>
<div class="w-full p-5 rounded-lg border border-blue-300 bg-blue-200 text-blue-900">Info Alert</div>
<div class="w-full p-5 rounded-lg border border-gray-200 bg-gray-100 text-gray-600">Light Alert</div>
<div class="w-full p-5 rounded-lg border border-gray-600 bg-gray-500 text-gray-900">Dark Alert</div>
</div>
<!-- alert with link -->
<div class="p-24 bg-green-600 flex flex-col justify-center items-center space-y-5">
<h3 class="pb-10 font-bold text-4xl text-green-900 text-center">Alert with Link Color</h3>
<div class="w-full p-5 rounded-lg border border-blue-400 bg-blue-300 text-blue-900">Primary Alert with matching <a href="#" class="font-bold underline">link</a> color.</div>
<div class="w-full p-5 rounded-lg border border-gray-500 bg-gray-400 text-gray-900">Secondary Alert with matching <a href="#" class="font-bold underline">link</a> color.</div>
<div class="w-full p-5 rounded-lg border border-green-400 bg-green-300 text-green-900">Success Alert with matching <a href="#" class="font-bold underline">link</a> color.</div>
<div class="w-full p-5 rounded-lg border border-red-400 bg-red-300 text-red-900">Danger Alert with matching <a href="#" class="font-bold underline">link</a> color.</div>
<div class="w-full p-5 rounded-lg border border-yellow-400 bg-yellow-300 text-yellow-900">Warning Alert with matching <a href="#" class="font-bold underline">link</a> color.</div>
<div class="w-full p-5 rounded-lg border border-teal-400 bg-teal-300 text-teal-900">Info Alert with matching <a href="#" class="font-bold underline">link</a> color.</div>
<div class="w-full p-5 rounded-lg border border-gray-200 bg-gray-100 text-gray-600">Light Alert with matching <a href="#" class="font-bold underline">link</a> color.</div>
<div class="w-full p-5 rounded-lg border border-gray-600 bg-gray-500 text-gray-900">Dark Alert with matching <a href="#" class="font-bold underline">link</a> color.</div>
</div>
<!-- headings, paragraphs, dividers -->
<div class="p-24 bg-green-400 flex flex-col justify-center items-center space-y-5">
<h3 class="pb-10 font-bold text-4xl text-green-900 text-center">Headings, Paragraphs, and Dividers</h3>
<div class="w-full p-5 rounded-lg border border-green-400 bg-green-300 text-green-900 divide-y-2 divide-solid divide-green-400">
<h2 class="font-bold text-xl pb-2">Congratulations!</h2>
<p class="pt-2">You have successfully recreated Bootstrap's alert box in <a href="https://tailwindcss.com/" class="font-bold underline">Tailwind CSS</a>.</p>
</div>
<div class="w-full p-5 rounded-lg border border-yellow-400 bg-yellow-300 text-yellow-900 divide-y-2 divide-solid divide-yellow-400">
<h2 class="font-bold text-xl pb-2">Warning!</h2>
<p class="pt-2">May cause excessive fun when using Tailwind CSS.</p>
</div>
</div>
<!-- adding icons -->
<div class="p-24 bg-green-800 flex flex-col justify-center items-center space-y-5">
<h3 class="pb-10 font-bold text-4xl text-green-200 text-center">Adding Icons on Alerts</h3>
<div class="w-full p-5 rounded-lg border border-blue-400 bg-blue-300 text-blue-900 flex">
<span class="mr-2">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.828 14.828a4 4 0 01-5.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</span>
Primary Alert
</div>
<div class="w-full p-5 rounded-lg border border-gray-500 bg-gray-400 text-gray-900 flex">
<span class="mr-2">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</span>
Secondary Alert
</div>
<div class="w-full p-5 rounded-lg border border-green-400 bg-green-300 text-green-900 flex">
<span class="mr-2">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 10h4.764a2 2 0 011.789 2.894l-3.5 7A2 2 0 0115.263 21h-4.017c-.163 0-.326-.02-.485-.06L7 20m7-10V5a2 2 0 00-2-2h-.095c-.5 0-.905.405-.905.905 0 .714-.211 1.412-.608 2.006L7 11v9m7-10h-2M7 20H5a2 2 0 01-2-2v-6a2 2 0 012-2h2.5" />
</svg>
</span>
Success Alert
</div>
<div class="w-full p-5 rounded-lg border border-red-400 bg-red-300 text-red-900 flex">
<span class="mr-2">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</span>
Danger Alert
</div>
<div class="w-full p-5 rounded-lg border border-yellow-400 bg-yellow-300 text-yellow-900 flex">
<span class="mr-2">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
</svg>
</span>
Warning Alert
</div>
<div class="w-full p-5 rounded-lg border border-teal-400 bg-teal-300 text-teal-900 flex">
<span class="mr-2">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</span>
Info Alert
</div>
<div class="w-full p-5 rounded-lg border border-gray-200 bg-gray-100 text-gray-600 flex">
<span class="mr-2">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
</svg>
</span>
Light Alert
</div>
<div class="w-full p-5 rounded-lg border border-gray-600 bg-gray-500 text-gray-900 flex">
<span class="mr-2">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21" />
</svg>
</span>
Dark Alert
</div>
</div>
Also see: Tab Triggers