CSS Properties
CSS inset-inline Property
Photo Credit to CodeToFun
🙋 Introduction
The inset-inline
property in CSS is a logical property that helps control the inline-start and inline-end offset of an element.
This property is part of the CSS Logical Properties and Values Module, which provides properties that control layout in a way that is independent of the physical dimensions and writing modes of the document.
The inset-inline
property is especially useful for web developers working with different writing modes and languages that flow in various directions.
💡 Syntax
The syntax for the inset-inline
property allows you to set the inline offsets with one or two values.
element {
inset-inline: value;
}
element {
inset-inline: start-value end-value;
}
- value: A single value sets both the inline-start and inline-end offsets.
- start-value end-value: Two values set the inline-start and inline-end offsets individually.
🎛️ Default Value
The default value of the inset-inline
property is auto, which means the element will be positioned according to the normal flow of the document.
🏠 Property Values
Value | Description |
---|---|
length | Specifies a fixed offset. It can be any valid CSS length value (e.g., 10px, 2em). |
percentage | Specifies a percentage of the containing block's inline size. |
auto | The offset is determined by the browser. |
initial | Sets the property to its default value. |
inherit | Inherits the value from the parent element. |
📄 Example
In this example, we'll set the inset-inline
property to position a box 20px from the inline-start and 40px from the inline-end.
<!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 Example</title>
<style>
.box {
position: relative;
inset-inline: 20px 40px;
width: 100px;
height: 100px;
background-color: lightblue;
}
</style>
</head>
<body>
<h1>Box with Custom Inline Insets</h1>
<div class="box"></div>
</body>
</html>
🖥️ Browser Compatibility
The inset-inline
property is supported in most modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. However, it is always a good practice to test your website across different browsers to ensure compatibility.
🎉 Conclusion
The inset-inline
property is a valuable addition to CSS, providing more flexibility and control over element positioning in different writing modes.
By using logical properties like inset-inline
, you can create more adaptable and internationalized web designs. Experiment with this property to see how it can enhance the layout and responsiveness of 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 inset-inline Property), please comment here. I will help you immediately.