How to Use Tailwind Preflight via CDN

57 Views Asked by At

I am using Tailwind CSS through CDN in a pure HTML file. However, I am experiencing an issue where only some of the border color styles are being applied, possibly due to a lack of initialization through Preflight. In my understanding, adding Preflight code to reset the existing styles might be necessary.

Considering it's a combination of PHP and HTML, and npm usage is not feasible, I'm looking for a way to add Preflight through CDN. What are the methods to achieve this?

1

There are 1 best solutions below

0
Hasan Ahamed On

By including Preflight styles directly in your HTML file, you're ensuring that the necessary resets and baseline styles are applied without needing npm or additional build processes. However, keep in mind that this approach means you'll need to manually update the Preflight styles if Tailwind CSS releases updates.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Your Title</title>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
    <style>
        /*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
        /* ... Paste the Preflight styles here ... */
    </style>
</head>
<body>
    <!-- Your HTML content here -->
</body>
</html>