- Services
- Case Studies
- Technologies
- NextJs development
- Flutter development
- NodeJs development
- ReactJs development
- About
- Contact
- Tools
- Blogs
- FAQ
CSS Inline-Size A Versatile Property for Responsive Design
Adjust based on writing mode, with options like pixels, percentages, and keywords.
Enhance your web design with this flexible tool.
Introduction
The inline-size
CSS property defines the horizontal or vertical size of an element, depending on the writing mode. It’s similar to the width
or height
properties but adapts based on the writing-mode
. Introduced in September 2021, inline-size
is widely supported and essential for creating responsive layouts.
Definition
The inline-size
property sets the size of an element along the inline axis, which can be horizontal or vertical depending on the writing-mode
. If the writing mode is vertical (vertical-rl
or vertical-lr
), inline-size
corresponds to the height. If it’s horizontal (horizontal-tb
), inline-size
corresponds to the width.
Relationship to Writing Mode
The inline-size
property works with the writing-mode
property, which determines text direction. In vertical modes (vertical-rl
or vertical-lr
), inline-size
sets the height. In horizontal mode (horizontal-tb
), it sets the width. This relationship makes inline-size
adaptable for different text directions.
Syntax
Values
Length Values
- Examples:
300px
,25em
- Description: Fixed sizes using units like pixels (
px
) or ems (em
).
Percentage Values
- Examples:
75%
- Description: Size relative to the containing block.
Keyword Values
- Examples:
max-content
,min-content
,fit-content
,auto
- Description: Predefined keywords for specific purposes:
auto
: Browser calculates the size.max-content
: Size based on the largest content.min-content
: Size based on the smallest content.fit-content
: Size based on available space, with an optional maximum.
Global Values
- Examples:
inherit
,initial
,revert
,unset
- Description: Control inheritance and reset values:
inherit
: Inherits from parent.initial
: Uses the initial value.revert
: Reverts to default value.unset
: Resets to natural value.
Formal Definition
Property | Value |
---|---|
Initial Value | auto |
Applies To | Same as width and height |
Inherited | No |
Percentages | Inline size of the containing block |
Computed Value | Same as width and height |
Animation Type | A length, percentage, or calc() |
Formal Syntax
Examples
Setting Inline Size in Pixels
HTML:
CSS:
Setting Inline Size with Percentage
HTML:
CSS:
Setting Inline Size with fit-content
HTML:
CSS:
Specifications
Specification |
---|
CSS Logical Properties and Values Level 1 - Dimension Properties |
CSS Box Sizing Module Level 4 - Sizing Values |
Browser Compatibility
- Google Chrome: Supported since version 57.
- Microsoft Edge: Supported since version 79.
- Mozilla Firefox: Supported since version 41.
- Opera: Supported since version 44.
- Safari: Supported since version 12.1.
See Also
- The mapped physical properties:
width
andheight
writing-mode
References
Talk with CEO
We'll be right here with you every step of the way.
We'll be here, prepared to commence this promising collaboration.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.