CSS Properties
CSS min-inline-size Property
Photo Credit to CodeToFun
🙋 Introduction
The min-inline-size
property in CSS is used to set the minimum size of an element along the inline axis, which is the axis running in the direction of the text flow (left-to-right or right-to-left).
This property ensures that an element's width does not fall below a specified minimum value, helping to maintain layout consistency and avoid content overflow.
💡 Syntax
The syntax for the min-inline-size
property is as follows:
element {
min-inline-size: size;
}
Here, size can be a length value, a percentage, or the keyword auto.
🎛️ Default Value
The default value of the min-inline-size
property is auto, which means that there is no minimum size restriction applied, and the element can shrink as needed based on its content and surrounding layout.
🏠 Property Values
Value | Description |
---|---|
length | Defines a fixed minimum size, such as 200px, 10em, or 5rem. |
percentage | Defines a minimum size relative to the containing block’s inline size, such as 50%. |
auto | The default value that means no minimum size is set. |
📄 Example
In this example, we will set a minimum inline size for a <div> element to ensure it does not shrink below 300 pixels.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS min-inline-size Example</title>
<style>
.container {
border: 1px solid black;
min-inline-size: 300px;
}
</style>
</head>
<body>
<h1>Element with Minimum Inline Size</h1>
<div class="container">
This container will not shrink below 300px in width.
</div>
</body>
</html>
🖥️ Browser Compatibility
The min-inline-size
property is supported in modern browsers, but support may vary across older versions. It is advisable to test the property in the browsers you target to ensure consistent behavior.
🎉 Conclusion
The min-inline-size
property is useful for setting a minimum width for elements along the inline axis, helping to maintain layout integrity and prevent unwanted content overflow.
By using this property, you can ensure that your design remains consistent across different screen sizes and content variations. Experiment with different values to achieve the desired layout and responsiveness for your web projects.
👨💻 Join our Community:
Author
For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.
Buy me a coffee to make codetofun.com free for everyone.
Buy me a Coffee
If you have any doubts regarding this article (CSS min-inline-size Property), please comment here. I will help you immediately.