- Services
- Case Studies
- Technologies
- NextJs development
- Flutter development
- NodeJs development
- ReactJs development
- About
- Contact
- Tools
- Blogs
- FAQ
CSS Inset Simplify Element Positioning
Discover available options, examples, and browser compatibility.

Constituent Properties
The inset
property in CSS combines the functionality of the top
, right
, bottom
, and left
properties into a single declaration. This makes it easier to manage the positioning of an element.
Individual Properties:
top
: Sets the top offset of an element from its containing block.right
: Sets the right offset of an element from its containing block.bottom
: Sets the bottom offset of an element from its containing block.left
: Sets the left offset of an element from its containing block.
How It Works:
The inset
property accepts one to four values, which are applied in a specific order:
- One Value: Applies the same value to all four sides (top, right, bottom, left).
- Two Values: The first value applies to the top and bottom, and the second value applies to the left and right.
- Three Values: The first value applies to the top, the second value applies to the left and right, and the third value applies to the bottom.
- Four Values: The values are applied in the order of top, right, bottom, and left.
Example:
.example { position: absolute; inset: 10px 20px 30px 40px; /* top right bottom left */}
Benefits:
- Simplified Code: Reduces the amount of CSS needed to position elements.
- Consistent Layout: Ensures accurate positioning for a polished layout.
- Flexibility: Allows setting different offsets for each side of the element.
Syntax
The inset
property in CSS sets the offsets for the top, right, bottom, and left sides of an element. It accepts various values, including lengths, percentages, and keywords.
Basic Syntax:
inset: <top> <right> <bottom> <left>;
Value Types:
- Length Values:
px
,em
,rem
,cm
,mm
,in
,pt
,pc
,ch
,vh
,vw
,vmin
. - Percentage Values: Relative to the containing block’s size.
- Keyword Values:
auto
allows the browser to determine the offset size. - Global Values:
inherit
,initial
,revert
,revert-layer
,unset
.
Examples:
- Single Value:
inset: 10px; /* Applies 10px to all sides */
- Two Values:
inset: 4px 8px; /* Applies 4px to top and bottom, 8px to left and right */
- Three Values:
inset: 5px 15px 10px; /* Applies 5px to top, 15px to left and right, 10px to bottom */
- Four Values:
inset: 2.4em 3em 3em 3em; /* Applies 2.4em to top, 3em to right, 3em to bottom, 3em to left */
- Percentage Values:
inset: 10% 5% 5% 5%; /* Applies 10% to top, 5% to right, 5% to bottom, 5% to left */
- Keyword Value:
inset: auto; /* Browser determines the offset size */
- Global Values:
inset: inherit; /* Inherits the inset value from the parent element */inset: initial; /* Sets the inset value to its initial value */inset: revert; /* Reverts the inset value to the user-agent stylesheet value */inset: revert-layer; /* Reverts the inset value to the previous layer's value */inset: unset; /* Unsets the inset value */
Advanced Syntax:
The inset
property also supports the calc()
function and anchor positioning.
Example with calc()
:
inset: calc(50% + 10px) auto auto auto;
Example with Anchor Positioning:
inset: auto auto anchor(center) anchor(self-end);
Summary:
The inset
property provides a flexible way to set the offsets of an element. Its syntax is straightforward and supports a wide range of values, making it a powerful tool for web developers.
Values
The inset
property accepts various values for precise control over element positioning. These include length units, percentages, keywords, and global values. Understanding these values helps you use the inset
property effectively.
Types of Values:
- Length Values: Such as
px
,em
,rem
,cm
,mm
,in
,pt
,pc
,ch
,vh
,vw
,vmin
. - Percentage Values: Relative to the containing block’s size.
- Keyword Values:
auto
allows the browser to determine the offset size. - Global Values:
inherit
,initial
,revert
,revert-layer
,unset
.
Examples:
- Single Value:
inset: 10px; /* Applies 10px to all sides */
- Two Values:
inset: 4px 8px; /* Applies 4px to top and bottom, 8px to left and right */
- Three Values:
inset: 5px 15px 10px; /* Applies 5px to top, 15px to left and right, 10px to bottom */
- Four Values:
inset: 2.4em 3em 3em 3em; /* Applies 2.4em to top, 3em to right, 3em to bottom, 3em to left */
- Percentage Values:
inset: 10% 5% 5% 5%; /* Applies 10% to top, 5% to right, 5% to bottom, 5% to left */
- Keyword Value:
inset: auto; /* Browser determines the offset size */
- Global Values:
inset: inherit; /* Inherits the inset value from the parent element */inset: initial; /* Sets the inset value to its initial value */inset: revert; /* Reverts the inset value to the user-agent stylesheet value */inset: revert-layer; /* Reverts the inset value to the previous layer's value */inset: unset; /* Unsets the inset value */
Summary:
The inset
property simplifies element positioning by combining the top
, right
, bottom
, and left
properties. Its flexible syntax and range of values make it a valuable tool for creating responsive and visually appealing layouts.
Browser Compatibility
The inset
property is widely supported in modern browsers, ensuring consistent layouts. Here’s a quick overview:
Supported Browsers:
- Google Chrome: Version 87 and above
- Microsoft Edge: Version 87 and above
- Mozilla Firefox: Version 66 and above
- Opera: Version 73 and above
- Safari: Version 14.1 and above
Additional Information:
- Introduction Date: The
inset
property was introduced in September 2021 and has gained widespread support. - Compatibility Tables: For detailed information, check the MDN Web Docs and the full compatibility table.
Feedback and Reporting:
If you encounter issues or have feedback, you can provide it through the MDN baseline feedback survey.
Related Properties:
- Longhand Box Offset Properties:
- Mapped Logical Shorthands:
inset-block
: Sets the logical block offsets of an element.inset-inline
: Sets the logical inline offsets of an element.
margin
Shorthand Multi-Value Syntax:- The
margin
property in CSS uses a similar multi-value syntax to theinset
property, allowing you to set the margins of an element with a single declaration.
- The
Additional Resources:
- CSS Logical Properties and Values:
- For more information on CSS logical properties and values, refer to the MDN Web Docs.
Summary:
Understanding related properties and concepts can help you make the most of the inset
property in your web development projects. By exploring these resources, you can gain a deeper understanding of CSS positioning and create more efficient and effective layouts.






Talk with CEO
We'll be right here with you every step of the way.
We'll be here, prepared to commence this promising collaboration.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.