YouTip LogoYouTip

Tailwindcss Sizing

Tailwind CSS provides a set of concise utility classes to help developers quickly control element sizing in HTML. Here are some common sizing utility classes and their usage. * * * ## Width - w-* w-* is used to set the width of an element. Tailwind provides some predefined widths, supporting pixels, percentages, viewport units, etc. | Class Name | Meaning | Example | | --- | --- | --- | | `w-1/2` | Set width to half of parent element | `
Content
` | | `w-1/4` | Set width to one quarter of parent element | `
Content
` | | `w-1/2` | Set width to 100% of parent element | `
Content
` | | `w-screen` | Set width to viewport width | `
Content
` | | `w-64` | Set width to 16rem (256px) | `
Content
` | | `w-auto` | Width adapts to content | `
Content
` | Use utility classes like w-px, w-1, w-64 to set fixed widths for elements. ## Example
w-96
w-80
w-64
w-48
w-40
w-32
w-24
[Try it Β»](#) Use utility classes like w-full, w-1/2, w-2/5 to set percentage-based element widths. ## Example
w-1/2
w-1/2
w-2/5
w-3/5
w-1/3
w-2/3
w-1/4
w-3/4
w-1/5
w-4/5
w-1/6
w-5/6
w-full
[Try it Β»](#) Use w-screen to make elements span the entire viewport width.
If you need to remove the specified width of an element under specific conditions (e.g., at specific breakpoints), the w-auto utility can be useful:
## **Height** - `h-*` Height classes are used to set the height of elements, also supporting pixels, percentages, and viewport units. Common height utility classes include: | Class Name | Meaning | Example | | --- | --- | --- | | `h-16` | Set height to 4rem (64px) | `
Content
` | | `h-1/2` | Set height to half of parent element | `
Content
` | | `h-screen` | Set height to viewport height | `
Content
` | | `h-auto` | Height adapts to content | `
Content
` | Use utility classes like h-px, h-1, h-64 to set fixed heights for elements. ## Example
h-96
h-80
h-64
h-48
h-40
h-32
h-24
[Try it Β»](#) Use h-full to set the element's height to 100% of its parent element, provided the parent element has a defined height.
Use h-screen to make elements span the entire viewport height.
Use h-dvh to make elements span the entire viewport height, which also changes as the browser UI expands or contracts. Scroll up/down in the viewport to hide/show the browser UI: ## Example
[Try it Β»](#) Use h-lvh to set the element's height to the maximum possible height of the viewport. This behaves the same as 100vh. Scroll up/down in the viewport to hide/show the browser UI: ## Example
← Tailwindcss TypographyTailwindcss Flexbox And Grid β†’