CSS Inset Property

Learn via video course
FREE
View all courses
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
Topics Covered

Overview

Inset is a shorthand way of denoting the top, right, bottom, and/or left CSS properties. Regardless of the element's writing style, directionality, or text orientation, it defines physical offsets.

We will learn how to use the inset CSS property in this article with the help syntax and examples.

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Syntax

With the help of length, percentage, keyword values, and global values, we can define the inset values. It adheres to the same padding and margin multi-value syntax.

In order to declare offsets for the top, right, bottom, and left, we can take just one value, two value, three value or four values. These values run clockwise, beginning at top, just like padding and margin do.

Syntax:

inset in CSS

Length

The length takes a fixed sets of value defined in px, cm, pt etc. We can also take negative values and its default value is 0px.

Example:

Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science

Percentage

The <percentage> value is same as length but it sets the size in terms of percentage of the containing block.

Example:

Auto

It's the default value. When applied, the browser calculates the inset values.

Example:

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Inherit

When inherit is used, the inset property inherits the property of its parent element. It may or may not be its containing block.

Once this value is inherited, it is handled as if it were a <length>, <percentage>, or the auto keyword.

Similar to inherit we have some more properties like initial, revert, revert-layer, unset. Initial is used to set the value of the inset property to its default value, and Unset is used to unset the inset property and it is the default value.

Inset Logical Properties

When we discuss "logical" concepts, we are referring to the point at which the writing of the material begins.

inset-logical-properties

The following are four inset logical sub-properties:

Logical PropertyHorizontal Flow EquivalentWhat it Does
inset-block-starttopDescribes the offset for the starting edge in the direction opposite to the writing direction.
inset-inline-endrightIndicates the offset for the writing-direction termination edge.
inset-block-endbottomIndicates the offset for the finishing edge in the direction that is orthogonal to the writing direction.
inset-inline-startleftThe starting edge offset is specified, and based on the writing mode, direction, and text orientation of the element, it corresponds to a physical offset.

The four sub-properties mentioned above can also be combined into two more shorthand properties:

Logical PropertyShorthand ForWhat it Does
inset-inlineinset-inline-start inset-inline-endboth inset-inline-start and inset-inline-end can be specified with this single value. It takes two values: one defines inset-inline-start and the other inset-inline-end.
inset-blockinset-block-start inset-block-endboth inset-block-start and inset-block-end can be set with this single value. It takes two values, the first one indicates the beginning of the inset block, and the second value specifies its finish.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Examples

Setting Offsets for an Element

Using length:

using-length-property-to-set-offset

Using percentage:

using-percentage-property-to-set-offset

Browser Support

The following browsers fully supports the CSS property:

browser-support-css-inset-property

Conclusion

  • Inset property values are the same as box offsets like top, left, right and bottom properties, only the directions are logical.
  • Inset property is applicable to the positioned elements. It is not an inherited property.
  • The percentage value is relative to the size of the containing block in the corresponding axis.

Similar to inset CSS property, you can check and read more about the following CSS topics: