Hello there!
Let's learn something today.
YOU'RE BUILDING
Pharmasift Part I
ROADMAP
Frontend
DIFFICULTY LEVEL
Beginner
3. Delete CSS. Add Class
In this chapter, we'll remove existing CSS styles from your HTML file and replace them with Tailwind's utility classes for styling elements.
Existing CSS Styles:
Let's assume you have the following CSS styles in your HTML file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>CSS to Tailwind</title>
<style>
/* Existing CSS styles */
.container {
padding: 20px;
background-color: #3490dc;
color: white;
text-align: center;
}
.heading {
font-size: 24px;
font-weight: bold;
}
</style>
</head>
<body>
<div class="container">
<p class="heading">Hello, CSS!</p>
</div>
</body>
</html>
Transition to Tailwind:
Now, let's replace the existing CSS styles with Tailwind's utility classes directly applied to HTML elements:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>CSS to Tailwind</title>
<!-- Add Tailwind CSS via CDN -->
<link
href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css"
rel="stylesheet"
/>
</head>
<body>
<div class="p-4 bg-blue-500 text-white text-center">Hello, Tailwind!</div>
</body>
</html>
Now you know why Tailwind is used by millions of Front-end and Full-stack Engineers.
TIP - Don’t use ChatGPT in initial phase of learning Tailwind. Later on you can :’)