CSS | max-inline-size Property

The CSS max-inline-size property is used to create the maximum size of an element in the direction opposite of the writing direction. Like if the writing direction is horizontal then max-inline-size is equivalent to max-height, and if it is in vertical mode then equal to max-width.

Syntax:

max-inline-size: length | percentage | auto | none | min-content |
           max-content | fit-content | inherit | initial | unset;

Property values:

  • length: It sets a fixed value defined in px, cm, pt etc. Negative values are allowed. Its default value is 0px.
  • percentage (%): It is the same as length but the size is set in term of percentage of the window size.
  • auto: It is used when it is desired that the browser determines the block-size.
  • none: It is used when you don’t want to limit on the size of the box.
  • max-content: It is used when you preferred max-width on the size of the box.
  • min-content: It is used when you preferred min-width on the size of the box.
  • fit-content: It is used when you preferred exact-width on the size of the box.
  • initial: It is used to set the value of the max-inline-size property to its default value.
  • inherit: It is used when it is desired that the element inherits the max-inline-size property of its parent as its own.
  • unset: It is used unset the default max-inline-size.

Below examples illustrate the max-inline-size property in CSS:
Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<head
    <title>CSS | max-inline-size Property</title
    <style
        h1 { 
            color: green; 
        
          
        div { 
            background-color: green; 
            width: 200px; 
            height: 20px; 
        
          
        .one { 
            position: relative; 
            max-inline-size: 10px; 
            background-color: cyan; 
        
    </style
</head
  
<body
    <center
        <h1>Geeksforgeeks</h1
        <b>CSS | max-inline-size Property</b
        <br
        <br
        <div
            <p class="one"
                A Computer Science Portal for Geeks 
            </p
        </div
    </center
</body
  
</html>                     

chevron_right


Output:



Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<head
    <title>CSS | max-inline-size Property</title
    <style
        h1 { 
            color: green; 
        
          
        div { 
            background-color: green; 
            width: 200px; 
            height: 20px; 
        
          
        .one { 
            position: relative; 
            max-inline-size: auto; 
            background-color: cyan; 
        
    </style
</head
  
<body
    <center
        <h1>Geeksforgeeks</h1
        <b>CSS | max-inline-size Property</b
        <br
        <br
        <div
            <p class="one"
                A Computer Science Portal for Geeks 
            </p
        </div
    </center
</body
  
</html>                     

chevron_right


Output:

Supported Browsers: The browsers supported by max-inline-size property are listed below:

  • Firefox
  • Google Chrome
  • Edge
  • Opera

Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/max-inline-size




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.