CSS object-position property26 Mar 2025 | 2 min read This CSS property is used to specify the alignment of the content within the container. It is used with the object-fit property to describe how an element like <video> or <img> is positioned with x/y coordinates within its container. When using the object-fit property, the default value for object-position is 50% 50%, so, by default, all images are positioned in the center of their container. We can change the default alignment by using the object-position property. SyntaxValuesposition: It defines the position of the video or the image within the container. It takes two numerical values (such as 0 10px) in which the first value manages the x-axis, whereas the second value controls the y-axis. It can be a string (left, right or center) or can be number (in % or px). It allows negative values. Its default value is 50% 50%. We can use string values like the right top, left bottom, etc. initial: It sets the property to the default value. inherit: It inherits the property from its parent element. Now, lets' see some examples that will illustrate the object-position property. ExampleOutput After the execution of the program, we will get the output as shown in the below image. ![]() Example- using "center top"Output ![]() Example- using "right top"Output ![]() Example- using "left top"Output ![]() Example- using "initial"When we use the initial value, then the image will be positioned to the center. It is because the initial sets the property to its default value, which is 50% 50%. Output ![]() Next TopicCSS Columns |
property This CSS property specifies the orientation of characters in the line of content. It only applies to the vertical mode of content. This property does not affect elements with horizontal writing mode. It helps us to control the display of languages that use a vertical...
3 min read
Cascading Style Sheets (CSS) are the backbone of web design, allowing developers and designers to control the appearance of web pages. One crucial aspect of CSS is managing the borders of elements, which can significantly impact a website's overall look and feel. This comprehensive guide will...
6 min read
CSS Border-collapse Property Cascading Style Sheets (CSS) play a pivotal role in designing and styling web pages, offering a myriad of properties to control the layout and appearance of elements. One such property that holds significance in table formatting and design is border collapse. This property allows...
6 min read
property This CSS property allows the user to control the resizing of an element just by clicking or dragging the bottom right corner of the element This CSS property is used to define how an element is resizable by the user. It doesn't apply on the...
3 min read
Introduction A cheat sheet is a concise, quick-reference guide that provides essential information on a specific topic or subject. It serves as a handy reference tool for individuals seeking quick access to key details, formulas, or commands without the need to delve into extensive documentation. Cheat sheets...
4 min read
We've collected several free HTML and CSS code samples for dropdown menus in this post from dependable sources like CodePen, GitHub, and other trustworthy websites. Dropdown menus are a common and efficient method of organizing and presenting navigation choices on your website. You may choose the...
3 min read
You can create complex and flexible web designs with ease thanks to the CSS Grid layout framework. A two-grid based layout framework is shown, making it easier to create dynamic and adaptable page layouts. We will examine the foundations of CSS Grid, its traits, and how...
10 min read
Introduction In CSS, we can use the background-position property to specify the position of the background image. We can set the position of the image at a particular position. The position we have provided is related to the position layer of the background image. Syntax: We can implement the...
7 min read
CSS Navigation Bar What is a CSS Navigation Bar? In CSS, a navigation bar is, also known as a navbar used in an interface to provide navigation links or menus to various selectors or page users in website design. Users can easily navigate a website's content using...
8 min read
In web development and CSS (Cascading Style Sheets), "container" typically refers to an HTML element or a CSS class used to group and structure content within a webpage. A "CSS container" is not a specific term in CSS itself, but it generally refers to an HTML...
23 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India