Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS margin-inline-end Property

Posted in CSS Tutorial
Updated on Oct 03, 2024
By Mari Selvan
👁️ 10 - Views
⏳ 4 mins
💬 1 Comment
CSS margin-inline-end Property

Photo Credit to CodeToFun

🙋 Introduction

The margin-inline-end property in CSS is part of the Logical Properties and Values module.

This property sets the margin space on the end side of an element, based on the writing mode, directionality, and text orientation of the document.

Unlike physical properties like margin-right, margin-inline-end adapts to the writing mode, making it more versatile for internationalization and responsive design.

💡 Syntax

The syntax for the margin-inline-end property is straightforward. It accepts any valid CSS length, percentage, or the keywords auto or inherit.

Syntax
Copied
Copy To Clipboard
element {
  margin-inline-end: value;
}
  • value: Can be a length (e.g., px, em, rem), percentage, or keywords like auto or inherit.

🎛️ Default Value

The default value of the margin-inline-end property is 0, meaning no margin is applied by default.

🏠 Property Values

ValueDescription
lengthSpecifies a fixed margin size. For example, 20px, 1em.
percentageSets the margin as a percentage of the containing block's inline size.
autoThe browser calculates the margin.
inheritInherits the margin value from the parent element.

📄 Example

In this example, we'll apply a margin of 20px to the inline end side of a <div> element.

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 margin-inline-end Example</title>
  <style>
    .box {
      margin-inline-end: 20px;
      border: 1px solid #000;
      padding: 10px;
    }
  </style>
</head>
<body>
  <h1>Example of margin-inline-end</h1>
  <div class="box">
    This box has a margin-inline-end of 20px.
  </div>
</body>
</html>

🖥️ Browser Compatibility

The margin-inline-end property is widely supported in modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. However, always ensure to test your website across different browsers to maintain consistent styling.

🎉 Conclusion

The margin-inline-end property is a valuable addition for developers looking to create responsive and adaptable layouts, especially for websites that need to support different languages and writing modes.

By using logical properties like margin-inline-end, you can simplify your CSS and make your designs more flexible. Experiment with different values and see how this property can enhance your layouts.

👨‍💻 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