Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS inset-inline Property

Posted in CSS Tutorial
Updated on Oct 03, 2024
By Mari Selvan
👁️ 14 - Views
⏳ 4 mins
💬 1 Comment
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.

Syntax
Copied
Copy To Clipboard
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

ValueDescription
lengthSpecifies a fixed offset. It can be any valid CSS length value (e.g., 10px, 2em).
percentageSpecifies a percentage of the containing block's inline size.
autoThe offset is determined by the browser.
initialSets the property to its default value.
inheritInherits 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.

index.html
Copied
Copy To Clipboard
<!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:

To get interesting news and instant updates on Front-End, Back-End, CMS and other Frameworks. Please Join the Telegram Channel:

Author

author
👋 Hey, I'm Mari Selvan

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

Share Your Findings to All

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy
AgreeCookie Policy