Tillitsdone
down Scroll to discover

CSS Inline-Size A Versatile Property for Responsive Design

CSS inline-size is a versatile property for defining element size along the inline axis.

Adjust based on writing mode, with options like pixels, percentages, and keywords.

Enhance your web design with this flexible tool.
thumbnail

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

/* <length> values */
inline-size: 300px;
inline-size: 25em;
inline-size: anchor-size(width);
inline-size: anchor-size(--myAnchor inline);
/* <percentage> values */
inline-size: 75%;
/* Keyword values */
inline-size: max-content;
inline-size: min-content;
inline-size: fit-content;
inline-size: fit-content(20em);
inline-size: auto;
/* Global values */
inline-size: inherit;
inline-size: initial;
inline-size: revert;
inline-size: revert-layer;
inline-size: unset;

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

PropertyValue
Initial Valueauto
Applies ToSame as width and height
InheritedNo
PercentagesInline size of the containing block
Computed ValueSame as width and height
Animation TypeA length, percentage, or calc()

Formal Syntax

inline-size = <width>
<width> =
auto |
<length-percentage [0,]> |
min-content |
max-content |
fit-content( <length-percentage [0,]> ) |
<calc-size()> |
<anchor-size()>
<length-percentage> =
<length> |
<percentage>
<calc-size()> =
calc-size( <calc-size-basis> , <calc-sum> )
<anchor-size()> =
anchor-size( [ <anchor-element> || <anchor-size> ]? , <length-percentage>? )
<calc-size-basis> =
<intrinsic-size-keyword> |
<calc-size()> |
any |
<calc-sum>
<anchor-element> =
<dashed-ident>
<anchor-size> =
width |
height |
block |
inline |
self-block |
self-inline
<calc-sum> =
<calc-product> [ [ '+' | '-' ] <calc-product> ]*
<calc-product> =
<calc-value> [ [ '*' | '/' ] <calc-value> ]*
<calc-value> =
<number> |
<dimension> |
<percentage> |
<calc-keyword> |
( <calc-sum> )
<calc-keyword> =
e |
pi |
infinity |
-infinity |
NaN

Examples

Setting Inline Size in Pixels

HTML:

<p class="exampleText">Example text</p>

CSS:

.exampleText {
writing-mode: vertical-rl;
background-color: yellow;
inline-size: 110px;
}

Setting Inline Size with Percentage

HTML:

<p class="exampleText">Example text</p>

CSS:

.exampleText {
writing-mode: horizontal-tb;
background-color: lightblue;
inline-size: 50%;
}

Setting Inline Size with fit-content

HTML:

<p class="exampleText">Example text</p>

CSS:

.exampleText {
writing-mode: horizontal-tb;
background-color: lightgreen;
inline-size: fit-content(20em);
}

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

References

icons/logo-tid.svg Latest Blogs
Discover our top articles, selected to support the growth of your business.
https://imgproxy-landing-page.tillitsdone.com/sig/rs:fit:1200:630/plain/https%3A%2F%2Fcms-r2.tillitsdone.com%2Fwp-content-prod%2Fuploads%2F2025%2F09%2FTill-its-done_SEO_R29_Sep_1440x697.jpg@webp สร้างเว็บขายของออนไลน์ด้วยตัวเอง เปรียบเทียบ Shopify vs WooCommerce เลือกอะไรดี? เรียนรู้วิธีสร้างเว็บขายของออนไลน์ด้วย Shopify หรือ WooCommerce เลือกแพลตฟอร์มที่ตอบโจทย์ธุรกิจคุณ พร้อมคำแนะนำและขั้นตอนละเอียดในบทความนี้! https://imgproxy-landing-page.tillitsdone.com/sig/rs:fit:1200:630/plain/https%3A%2F%2Fcms-r2.tillitsdone.com%2Fwp-content-prod%2Fuploads%2F2025%2F09%2FTill-its-done_SEO_R27_Sep_1440x697.jpg@webp เปรียบเทียบ 3 วิธีติดตั้ง install node js บน Ubuntu: NVM vs NodeSource vs Official Repo แบบไหนดีที่สุด? เรียนรู้วิธีติดตั้ง Node.js บน Ubuntu ด้วย NVM, NodeSource หรือ Official Repo เลือกวิธีที่เหมาะกับความต้องการของคุณ พร้อมเปรียบเทียบ เพื่อการพัฒนาที่มีประสิทธิภาพ! https://imgproxy-landing-page.tillitsdone.com/sig/rs:fit:1200:630/plain/https%3A%2F%2Fcms-r2.tillitsdone.com%2Fwp-content-prod%2Fuploads%2F2025%2F09%2FTill-its-done_SEO_R26_Sep_1440x697.jpg@webp Next js image การ Optimization รูปภาพแบบ Native ที่มีประสิทธิภาพสูง เรียนรู้วิธีใช้ Next.js Image เพื่อ Optimization การแสดงภาพบนเว็บไซต์ ด้วยเทคนิคบีบอัด ปรับขนาด Lazy Load และรองรับ Responsive ช่วยให้เว็บคุณโหลดเร็วขึ้นแน่นอน! https://imgproxy-landing-page.tillitsdone.com/sig/rs:fit:1200:630/plain/https%3A%2F%2Fcms-r2.tillitsdone.com%2Fwp-content-prod%2Fuploads%2F2025%2F08%2FTill-its-done_SEO_R24_Sep_1440x697.jpg@webp เจาะลึก Cross Platform App คืออะไร? ใช่ทางเลือกใหม่ที่ดีกว่า Native จริงหรือไม่ เรียนรู้เกี่ยวกับ Cross Platform App ทางเลือกใหม่ในการพัฒนาแอป พร้อมข้อดี-ข้อเสีย และทักษะที่จำเป็นเพื่อสร้างแอปคุณภาพสูง อ่านเพิ่มเติมได้ที่นี่! https://imgproxy-landing-page.tillitsdone.com/sig/rs:fit:1200:630/plain/https%3A%2F%2Fcms-r2.tillitsdone.com%2Fwp-content-prod%2Fuploads%2F2025%2F08%2FTill-its-done_SEO_R22_June_1440x697.jpg@webp Flutter Developer คืออะไร? สำคัญแค่ไหน Flutter Developer คือผู้เชี่ยวชาญด้านการพัฒนาแอปมือถือด้วย Flutter ที่ช่วยสนับสนุนธุรกิจให้เติบโตอย่างรวดเร็วและคุ้มค่า ด้วยเทคโนโลยีที่ยืดหยุ่นและประหยัดต้นทุน https://imgproxy-landing-page.tillitsdone.com/sig/rs:fit:1200:630/plain/https%3A%2F%2Fcms-r2.tillitsdone.com%2Fwp-content-prod%2Fuploads%2F2025%2F07%2FTill-its-done_SEO_R16_June_1440x697-1.jpg@webp จุดเด่นของ React JS คือ ดียังไงกับการทำ Mobile App React JS เป็นไลบรารีที่สนับสนุนการพัฒนาแอปพลิเคชันแบบ Single Page พร้อมรองรับการสร้างแอปบนมือถือด้วย React Native แต่ทำอย่างไร มาดูกันครับ
icons/logo-tid.svg

พูดคุยกับซีอีโอ

พร้อมที่จะสร้างเว็บ/แอปของคุณให้มีชีวิตชีวาหรือเสริมทีมของคุณด้วยนักพัฒนาชาวไทยผู้เชี่ยวชาญหรือไม่?
ติดต่อเราวันนี้เพื่อหารือเกี่ยวกับความต้องการของคุณ แล้วมาสร้างโซลูชันที่ปรับแต่งเพื่อบรรลุเป้าหมายของคุณกัน เรายินดีช่วยเหลือทุกขั้นตอน!
🖐️ Contact us
down Explore our best articles, cover a wide variety of technologies
Our knowledge base
Let's keep in Touch
Thank you for your interest in Tillitsdone! Whether you have a question about our services, want to discuss a potential project, or simply want to say hello, we're here and ready to assist you.
We'll be right here with you every step of the way.
Contact Information
rick@tillitsdone.com+66824564755
Find All the Ways to Get in Touch with Tillitsdone - We're Just a Click, Call, or Message Away. We'll Be Right Here, Ready to Respond and Start a Conversation About Your Needs.
Address
9 Phahonyothin Rd, Khlong Nueng, Khlong Luang District, Pathum Thani, Bangkok Thailand
Visit Tillitsdone at Our Physical Location - We'd Love to Welcome You to Our Creative Space. We'll Be Right Here, Ready to Show You Around and Discuss Your Ideas in Person.
Social media
FacebookInstagramLinkedIn
Connect with Tillitsdone on Various Social Platforms - Stay Updated and Engage with Our Latest Projects and Insights. We'll Be Right Here, Sharing Our Journey and Ready to Interact with You.
We anticipate your communication and look forward to discussing how we can contribute to your business's success.
We'll be here, prepared to commence this promising collaboration.
Frequently Asked Questions
Explore frequently asked questions about our products and services.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.