DEV Community

Arhan Khan
Arhan Khan

Posted on

Tailwind CSS for Beginners: Style Your Website Without Leaving Your HTML

Tailwind CSS is a utility-first CSS framework. Instead of writing custom CSS classes like .card and .button, you style elements directly in your HTML with small utility classes like p-4, bg-blue-500, and rounded-lg. It feels strange for about ten minutes, and then it feels faster than anything else.

How does it work? You add Tailwind to your project, then write classes in your markup. Each class does one small thing — padding, colour, font size, layout — and you combine them to build any design. When you build for production, Tailwind scans your files and generates only the CSS you actually used, so the final stylesheet stays tiny.

<!-- A card, styled entirely with utilities -->
<div class="max-w-sm rounded-lg bg-white p-6 shadow-md">
  <h2 class="text-xl font-bold text-gray-900">Hello, Tailwind</h2>
  <p class="mt-2 text-gray-600">No separate CSS file needed.</p>
  <button class="mt-4 rounded bg-blue-600 px-4 py-2 text-white hover:bg-blue-700">
    Get started
  </button>
</div>
Enter fullscreen mode Exit fullscreen mode

Tailwind is great for beginners because you never have to name a CSS class or switch files to style something. The class names are predictable — mt-4 is always margin-top, text-lg is always a large font — so you learn the system by using it, not by reading docs for hours. And if you are learning web development alongside design, Skill Library has beginner-friendly eBooks on web development and self-growth that pair well with hands-on practice like this.

When should you use Tailwind? For almost any website or web app, from a landing page to a dashboard. It shines when you want a custom design without writing hundreds of lines of CSS, and it works well with React, Vue, Astro, and plain HTML.

The limits are worth knowing. Long class lists can make HTML look messy at first, and you will need to learn the naming system before it feels fast. For very large projects, you will eventually want to extract repeated patterns into components — which is exactly what component frameworks are for.

Start today: add Tailwind to a small page, build a card like the one above, and change the colours and spacing until it looks like your own design. Once you stop reaching for a separate CSS file, you have learned the core idea.

Top comments (0)