CSS - inline-size Property



The inline-size property of CSS determines the horizontal or vertical size of an element's inline, based on the writing mode of the element. It relates to the width or the height properties of CSS, based on the value of writing-mode.

When the writing mode is vertically orientated, the value of inline-size relates to the height of the element, else it relates to the width of the element.

Possible Values

The CSS property inline-size takes the same value as the width and height properties.

Applies To

All elements but non-replaced inline elements, table rows, and row groups.

Syntax

Following are the different ways in which the inline-size can be declared:

Length Value

inline-size: 100px;
inline-size: 20em;

percentage Value

inline-size: 45%;

Keyword Value

inline-size: max-content;
inline-size: min-content;
inline-size: fit-content;
inline-size: auto;

Global Value

inline-size: inherit;
inline-size: initial;
inline-size: revert;
inline-size: revert-layer;
inline-size: unset;

CSS inline-size - Using Length Values

Following example demonstrates the output with writing-mode: vertical-rl and inline-size is given a length value:

<html>
<head>
<style>
   .container {
      writing-mode: vertical-rl;
      background-color: pink;
      border: 2px solid blue;
      display: inline-block;
   }

   .sampleText-px {
      inline-size: 100px;
   }

   .sampleText-em {
      inline-size: 20em;
   }
</style>
</head>
<body>
   <h2>inline-size - length value with writing-mode: vertical-rl</h2>
   <div class="container sampleText-px">Sample Text-px</div>
   <div class="container sampleText-em">Sample Text-em</div>
</body>
</html>

Following example demonstrates the output with writing-mode: horizontal-tb and inline-size is given a length value:

<html>
<head>
<style>
   .container {
      writing-mode: horizontal-tb;
      background-color: pink;
      border: 2px solid blue;
      display: inline-block;
   }

   .sampleText-px {
      inline-size: 100px;
   }

   .sampleText-em {
      inline-size: 20em;
   }
</style>
</head>
<body>
   <h2>inline-size - length value with writing-mode: horizontal-tb</h2>
   <div class="container sampleText-px">Sample Text-px</div>
   <div class="container sampleText-em">Sample Text-em</div>
</body>
</html>

CSS inline-size - Using Percentage Values

Following example demonstrates the output with writing-mode: vertical-rl and inline-size is given as a percentage value:

<html>
<head>
<style>
   .container {
      writing-mode: vertical-rl;
      background-color: pink;
      border: 2px solid blue;
      display: inline-block;
   }

   .sampleText-10per {
      inline-size: 10%;
   }

   .sampleText-65per {
      inline-size: 65%;
   }
</style>
</head>
<body>
   <h2>inline-size - percentage value with writing-mode: vertical-rl</h2>
   <div class="container sampleText-10per">Sample Text-10%</div>
   <div class="container sampleText-65per">Sample Text-65%</div>
</body>
</html>

Following example demonstrates the output with writing-mode: horizontal-tb and inline-size is given as a percentage value:

<html>
<head>
<style>
   .container {
      writing-mode: horizontal-tb;
      background-color: pink;
      border: 2px solid blue;
      display: inline-inline;
   }

   .sampleText-10per {
      inline-size: 10%;
   }

   .sampleText-65per {
      inline-size: 65%;
   }
</style>
</head>
<body>
   <h2>inline-size - percentage value with writing-mode: horizontal-tb</h2>
   <div class="container sampleText-10per">Sample Text-10%</div>
   <div class="container sampleText-65per">Sample Text-65%</div>
</body>
</html>

CSS inline-size - Using Keyword Values

Following example demonstrates the output with writing-mode: vertical-rl and inline-size is given as a keyword value:

<html>
<head>
<style>
   .container {
      writing-mode: vertical-rl;
      background-color: pink;
      border: 2px solid blue;
      display: inline-block;
   }

   .sampleText-auto {
      inline-size: auto;
   }

   .sampleText-max {
      inline-size: max-content;
   }

   .sampleText-min {
      inline-size: min-content;
   }

   .sampleText-fit {
      inline-size: fit-content;
   }
</style>
</head>
<body>
   <h2>inline-size - keyword value with writing-mode: vertical-rl</h2>
   <div class="container sampleText-auto">Sample Text - auto</div>
   <div class="container sampleText-max">Sample Text - max-content</div>
   <div class="container sampleText-min">Sample Text - min-content</div>
   <div class="container sampleText-fit">Sample Text - fit-content feature</div>
</body>
</html>

Following example demonstrates the output with writing-mode: horizontal-tb and inline-size is given as a keyword value:

<html>
<head>
<style>
   .container {
      writing-mode: horizontal-tb;
      background-color: pink;
      border: 2px solid blue;
      display: inline-block;
   }

   .sampleText-auto {
      inline-size: auto;
   }

   .sampleText-max {
      inline-size: max-content;
   }

   .sampleText-min {
      inline-size: min-content;
   }

   .sampleText-fit {
      inline-size: fit-content;
   }
</style>
</head>
<body>
   <h2>inline-size - keyword value with writing-mode: horizontal-tb</h2>
   <div class="container sampleText-auto">Sample Text - auto</div>
   <div class="container sampleText-max">Sample Text - max-content</div>
   <div class="container sampleText-min">Sample Text - min-content</div>
   <div class="container sampleText-fit">Sample Text - fit-content feature</div>
</body>
</html>
Advertisements