Today I started learning Tailwind CSS and understood how to install it, use utility classes, and work with spacing and borders.
Installing Tailwind CSS
npm install tailwindcss @tailwindcss/vite
Tailwind CSS Classes
One of the main advantages of Tailwind CSS is that we can style HTML elements directly using predefined utility classes
Button
Border Colors and Border Sides
Tailwind
Meaning
border-l
Border Left
border-r
Border Right
border-t
Border Top
border-b
Border Bottom
it is not a internal because it have prebulid .Tailwind
Meaning
border-l Border Left
border-r Border Right
border-t Border Top
border-b Border Bottom
For example:
Content
This applies a border only to the left side.
We can also apply a border color using Tailwind's color utilities.
- Tailwind CSS is Not Internal CSS
Tailwind CSS is different from writing normal internal CSS.
Normally, we might write:
button {
border: 1px solid black;
}
But with Tailwind CSS, we can directly write utility classes:
Button
Tailwind provides pre-built utility classes that we can use directly in our HTML or JSX.
Padding in Tailwind CSS
Hello
In Tailwind CSS:
p-4 = 16px
So:
applies 16px padding on all four sides
Margin in Tailwind CSS
Class
Meaning
mt-*Margin Top
mr-*Margin Right
ml-*Margin Left
mb-*Margin Bottom
Top comments (0)