Search results
Learn how to use the z-index property to specify the stack order of an element in CSS. See examples, syntax, browser support, and related pages.
- Try It Yourself
The W3Schools online code editor allows you to edit code and...
- CSS Layout
The z-index Property. When elements are positioned, they can...
- zIndex Property
Change the stack order of an <img> element: The zIndex...
- W3Schools CSS z-index demonstration
Demo of the different values of the z-index property.
- Try It Yourself
Learn how to use the z-index property to specify the stack order of positioned elements and flex items. See examples, exercises and code snippets on W3Schools.
Change the stack order of an <img> element: The zIndex property sets or returns the stack order of a positioned element. An element with greater stack order (1) is always in front of another element with lower stack order (0). Tip: A positioned element is an element with the position property set to: relative, absolute, or fixed.
The z-index Property. Because the image has a z-index of -1, it will be placed behind the text.
Demo of the different values of the z-index property.
The W3Schools online code editor allows you to edit code and view the result in your browser
The z-index property specifies the stack order of an element. An element with greater stack order is always in front of an element with a lower stack order. Note: z-index only works on positioned elements (position: absolute, position: relative, position: fixed, or position: sticky).