Bootstrap 5 Basic
Bootstrap 5 Flexbox
In Bootstrap 5, width utility classes provide an easy way to set the width of elements. These utilities can be used to control the width relative to the parent, viewport, or specific values.
w-{side?}
w
: Indicates width.value
: The width value, which can be a percentage, fixed size, or responsive scale.Bootstrap includes predefined width classes that set the width as a percentage of the parent container:
Class |
Description |
---|---|
w-25 |
Width: 25% of the parent container. |
w-50 |
Width: 50% of the parent container. |
w-75 |
Width: 75% of the parent container. |
w-100 |
Width: 100% of the parent container. |
w-auto |
Automatically adjusts to content. |
Try it yourself
Bootstrap also provides classes to limit the maximum width of elements:
Class |
Description |
---|---|
mw-100 |
Max width: 100% of the parent. |
mw-auto |
Automatically adjusts width. |
Try it yourself