In the article, we will go into detail on how to use font-size
.
Font Size
Format
text-{size}
Alignment | Tailwind Class | CSS Property |
---|---|---|
text-xs | text-xs |
font-size: 0.75rem; /* 12px */ , line-height: 1rem; /* 16px */ |
text-sm | text-sm |
font-size: 0.875rem; /* 14px */ , line-height: 1.25rem; /* 20px */ |
text-base | text-base |
font-size: 1rem; /* 16px */ , line-height: 1.5rem; /* 24px */ |
text-lg | text-lg |
font-size: 1.125rem; /* 18px */ . line-height: 1.75rem; /* 28px */ |
text-xl | text-xl |
font-size: 1.25rem; /* 20px */ , line-height: 1.75rem; /* 28px */ |
text-2xl | text-2xl |
font-size: 1.5rem; /* 24px */ line-height: 2rem; /* 32px */ |
The font-size property in CSS is used to set the font size of text in HTML document.
-
text-xs: This class defines the text size as extra small.
-
text-sm: This class defines the text size as small.
-
text-base: This class defines the text size as base size.
-
text-lg: This class defines the text size as large.
-
text-xl: This class defines the text size as extra-large.
-
text-2xl: This class defines the text size as 2 times extra-large.
-
text-3xl: This class defines the text size as 3 times extra-large.
-
text-4xl: This class defines the text size as 4 times extra-large.
-
text-5xl: This class defines the text size as 5 times extra-large.
-
text-6xl: This class defines the text size as 6 times extra-large.
-
text-7xl: This class defines the text size as 7 times extra-large.
-
text-8xl: This class defines the text size as 8 times extra-large.
-
text-9xl: This class defines the text size as 9 times extra-large.
–
class="container mx-auto leading-none divide-y divide-gray-400 divide-dotted" style="font-family: Raleway">
- class="flex items-center justify-between px-4 py-2">
class="text-xs align-middle mb-2">Hello World
class="text-xs font-mono font-light leading-tight text-gray-500"> class="font-bold">font-size:: 0.75rem; class="font-bold">line-height:: 1rem;
class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">text-xs
- class="flex items-center justify-between px-4 py-2">
class="text-sm align-middle mb-2">Hello World
class="text-xs font-mono font-light leading-tight text-gray-500"> class="font-bold">font-size:: 0.875rem; class="font-bold">line-height:: 1.25rem;
class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">text-sm
- class="flex items-center justify-between px-4 py-2">
class="text-base align-middle mb-2">Hello World
class="text-xs font-mono font-light leading-tight text-gray-500"> class="font-bold">font-size:: 1rem; class="font-bold">line-height:: 1.5rem;
class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">text-base
- class="flex items-center justify-between px-4 py-2">
class="text-lg align-middle mb-2">Hello World
class="text-xs font-mono font-light leading-tight text-gray-500"> class="font-bold">font-size:: 1.125rem; class="font-bold">line-height:: 1.75rem;
class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">text-lg
- class="flex items-center justify-between px-4 py-2">
class="text-xl align-middle mb-2">Hello World
class="text-xs font-mono font-light leading-tight text-gray-500"> class="font-bold">font-size:: 1.25rem; class="font-bold">line-height:: 1.75rem;
class="text-xs font-medium font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">text-xl
- class="flex items-center justify-between px-4 py-2">
class="text-2xl align-middle mb-2">Hello World
class="text-xs font-mono font-light leading-tight text-gray-500"> class="font-bold">font-size:: 1.5rem; class="font-bold">line-height:: 2rem;
class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">text-2xl
- class="flex items-center justify-between px-4 py-2">
class="text-3xl align-middle mb-2">Hello World
class="text-xs font-mono font-light leading-tight text-gray-500"> class="font-bold">font-size:: 1.875rem; class="font-bold">line-height:: 2.25rem;
class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">text-3xl
- class="flex items-center justify-between px-4 py-2">
class="text-4xl align-middle mb-2">Hello World
class="text-xs font-mono font-light leading-tight text-gray-500"> class="font-bold">font-size:: 2.25rem; class="font-bold">line-height:: 2.5rem;
class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">text-4xl
- class="flex items-center justify-between px-4 py-2">
class="text-5xl align-middle mb-2">Hello World
class="text-xs font-mono font-light leading-tight text-gray-500"> class="font-bold">font-size:: 3rem; class="font-bold">line-height:: 1;
class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">text-5xl
- class="flex items-center justify-between px-4 py-2">
class="text-6xl align-middle mb-2">Hello World
class="text-xs font-mono font-light leading-tight text-gray-500"> class="font-bold">font-size:: 3.75rem; class="font-bold">line-height:: 1rem;
class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">text-6xl
- class="flex items-center justify-between px-4 py-2">
class="text-7xl align-middle mb-2">Hello World
class="text-xs font-mono font-light leading-tight text-gray-500"> class="font-bold">font-size:: 4.5rem; class="font-bold">line-height:: 1rem;
class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">text-7xl
- class="flex items-center justify-between px-4 py-2">
class="text-8xl align-middle mb-2">Hello World
class="text-xs font-mono font-light leading-tight text-gray-500"> class="font-bold">font-size:: 6rem; class="font-bold">line-height:: 1rem;
class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">text-8xl
- class="flex items-center justify-between px-4 py-2">
class="text-9xl align-middle mb-2">Hello World
class="text-xs font-mono font-light leading-tight text-gray-500"> class="font-bold">font-size:: 8rem; class="font-bold">line-height:: 1rem;
class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">text-9xl
Full code:
The overall code will be attached to repo link.
Resources:
tailwind.css
Thank you for reading :), To learn more, check out my blogs on Justify-Content, Responsive Navbar and Justify-Item.
If you liked this article, consider following me on Dev.to for my latest publications. You can reach me on Twitter.
Keep learning! Keep coding!! 💛