×

Tailwind CSS Width

The tailwind CSS width class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS Width Property. This class is used to specify the text and image widths. Text and pictures can be given widths in pixels (px), percentages (%), centimeters (cm), and other units.

Width Classes

The various width classes are as follows:

  • w-0: This class indicates that the width is zero.
  • w-auto: This class indicates that the width is determined by the content.
  • w-1/2: This class indicates that the window's width is set to half.
  • w-1/3: This class indicates that the width of the window is set to one-third of the whole width.
  • w-1/4: This class indicates that the width of the window is set to one-fourth of the total width.
  • w-1/5: This class indicates that the window's width is set to one-fifth of its original size.
  • w-1/6: This class indicates that the width of the window is set to one-sixth of the whole width.
  • w-1/12: This class specifies that the width of the window is one-twelfth of the whole width.
  • w-full: This class indicates that the width has been set to 100%.
  • w-screen: This class indicates that the width is set to the width of the screen.
  • w-min: The min-width is defined by this class.
  • w-max: The max-width is defined by this class.

Note: You can adjust the number or set the percentage value by using the valid "rem" values.

Syntax:

<element class="w-0">...</element>

Example:

Consider the below code:

<!DOCTYPE html>
<head>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
<body class="text-center mx-4 space-y-2">
    <h1 class="text-red-600 text-5xl font-bold">
        Tutorial and Example
    </h1>
    <b>Width Class - Tailwind CSS </b>
    <div class="flex">
        <div class="w-1/2 bg-red-600 h-12 rounded-l-lg">
          w-1/2
        </div>
        <div class="w-1/2 bg-red-300 h-12 rounded-r-lg">
          w-1/2
        </div>
    </div>
    <div class="flex ...">
      <div class="w-2/5 bg-red-600 h-12 rounded-l-lg">
          w-2/5
      </div>
      <div class="w-3/5 bg-red-300 h-12 rounded-r-lg">
          w-3/5
      </div>
    </div>
    <div class="flex ...">
      <div class="w-1/3 bg-red-600 h-12 rounded-l-lg">
          w-1/3
      </div>
      <div class="w-2/3 bg-red-300 h-12 rounded-r-lg">
          w-2/3
      </div>
    </div>
    <div class="flex ...">
      <div class="w-1/4 bg-red-600 h-12 rounded-l-lg">
          w-1/4
      </div>
      <div class="w-3/4 bg-red-300 h-12 rounded-r-lg">
          w-3/4
      </div>
    </div>
    <div class="flex ...">
      <div class="w-1/5 bg-red-600 h-12 rounded-l-lg">
          w-1/5
      </div>
      <div class="w-4/5 bg-red-300 h-12 rounded-r-lg">
          w-4/5
      </div>
    </div>
    <div class="flex ...">
      <div class="w-1/6 bg-red-600 h-12 rounded-l-lg">
          w-1/6
      </div>
      <div class="w-5/6 bg-red-300 h-12 rounded-r-lg">
          w-5/6
      </div>
    </div>
    <div class="w-full bg-red-300 h-12 rounded-lg">
          w-full
    </div>
</body>
</html>

Output:

Tailwind CSS Width

Related Topics

Tailwind CSS Place Items

This class accepts a wide range of values. It's a replacement for the CSS Place Items property. This class is used to manage how things are justified while still being...

4 minutes read.

Tailwind CSS Overflow

The overflow class acknowledges more than one value in Tailwind CSS. It is an option in contrast to the CSS Overflow property. This overflow is for controlling how element content...

9 minutes read.

Tailwind CSS Visibility

In tailwind CSS, this class accepts two values. It's a replacement for the CSS visibility property. This class specifies whether an element in a web document is visible or not,...

2 minutes read.

Tailwind CSS Box Sizing

Tailwind CSS Box sizing class acknowledges more than one worth in tailwind CSS. Each property is shrouded as a class structure. It is an option in contrast to the CSS...

2 minutes read.

Tailwind CSS Float

The float class acknowledges more than one worth (value) in tailwind CSS. It is an option in contrast to the CSS float property. The float class characterizes the progression of...

4 minutes read.

Tailwind CSS Flex Shrink

CSS flexbox is an important element for frontend development. There are two flex-shrink options in Tailwind CSS, and all properties are covered in class form. For quick front-end development, it's...

3 minutes read.

Tailwind CSS Min-Width

In tailwind CSS, this class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS min-width property. This...

1 minute read.

Tailwind CSS Min-Height

In tailwind CSS, this class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS Min-Height Property. It...

2 minutes read.

Tailwind CSS Flex Wrap

CSS flexbox is an important component for frontend development. It is a front-end development alternative to the CSS flex-wrap Property. Note: You must include the flex class in your element before...

4 minutes read.

Tailwind CSS Place Self

The tailwind CSS Place self class accepts a wide range of values. It's a replacement for the CSS Place Items property. This class is used to manage how a single...

4 minutes read.

Tailwind CSS Grid Row Start / End

In tailwind CSS, this class takes several values. All of the attributes are covered in the form of a class. In CSS, it's an alternative to the grid-row attribute. It's...

4 minutes read.

Tailwind CSS Justify Content

In tailwind CSS, this class accepts two values. It's a replacement for CSS's justify-content attribute. This class is used to describe the flexible box container's alignment. Along the main axis...

4 minutes read.

Tailwind CSS Grid Auto Rows

In tailwind CSS, this class takes multiple values and covers all of the properties in class form. It's a replacement for the grid-auto-rows CSS attribute. The size of the rows...

6 minutes read.

Tailwind CSS Height

This class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS height property. This class is used...

4 minutes read.

Tailwind CSS Top / Right / Bottom / Left

In tailwind CSS, these classes take a variety of values and cover all of the characteristics in the class form. These are the CSS Top/Right/Bottom/Left properties' replacements. These classes are...

4 minutes read.

Tailwind CSS Gap

In tailwind CSS, this class accepts multiple values, and all of the properties are covered in class form. It's a replacement for the CSS gap attribute. This class is used...

4 minutes read.

Tailwind CSS Order

One of the best features of Tailwind CSS is the Order class, which allows us to order flex and grid objects according to our needs. There are several different order...

2 minutes read.

Tailwind CSS Z-index

The tailwind CSS framework is a CSS utility framework that provides classes for managing HTML content with CSS. Tailwind CSS simplifies our design process and makes it responsive across numerous...

4 minutes read.

Tailwind CSS Opacity

This class accepts a lot of value, and all of the properties are covered in class form. We can change the opacity of any element by using this class. The...

1 minute read.

Tailwind CSS Justify Self

The class form goes over the various properties. It's a replacement for the CSS justify-self attribute. This class is used to describe the alignment of content’s position in a CSS...

4 minutes read.