CSS Properties
CSS inset-inline-start Property
Photo Credit to CodeToFun
🙋 Introduction
The inset-inline-start
property in CSS is used to specify the offset from the start of the inline axis of an element's containing block.
In a left-to-right (LTR) writing mode, this is the left side, while in a right-to-left (RTL) writing mode, this is the right side.
This property is part of the Logical Properties and Values specification, which aims to provide more logical and adaptable ways to control layout, especially for internationalization.
💡 Syntax
The syntax for the inset-inline-start
property is simple and allows for various units to define the offset.
element {
inset-inline-start: length | percentage | auto;
}
🎛️ Default Value
The default value of the inset-inline-start
property is auto, which means that the position is determined by the normal flow of the document.
🏠 Property Values
Value | Description |
---|---|
length | Specifies a fixed offset. Can be any valid length value, such as px, em, rem, etc. |
percentage | Specifies an offset as a percentage of the containing block's width. |
auto | The position is determined by the normal document flow. |
📄 Example
In this example, we'll position a box 20 pixels from the start of the inline axis (left in LTR and right in RTL).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS inset-inline-start Example</title>
<style>
.box {
position: absolute;
inset-inline-start: 20px;
top: 10px;
width: 100px;
height: 100px;
background-color: lightblue;
}
</style>
</head>
<body>
<h1>Box Positioned with inset-inline-start</h1>
<div class="box"></div>
</body>
</html>
🖥️ Browser Compatibility
The inset-inline-start
property is supported in most modern browsers. However, it is recommended to test your website across different browsers to ensure consistent behavior, especially if you are working with internationalized content or need to support older browsers.
🎉 Conclusion
The inset-inline-start
property provides a logical and flexible way to control the positioning of elements relative to the start of the inline axis.
This is particularly useful in responsive design and internationalized websites, as it adapts to different writing modes. By using logical properties like inset-inline-start
, you can create more adaptable and future-proof layouts.
👨💻 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 inset-inline-start Property), please comment here. I will help you immediately.