CSS z-index Property

In this chapter you will learn:
About z-index property
Values of this property
Example of this property

CSS z-index property is used to specify the z-index of an element. This property can only work if the element is positioned absolute, relative or fixed. If the element is positioned normal then it can’t work with that element.

Values of this property
Values Description
auto This is the default value which sets the stack order.
number Specify the number to set the stack order
initial Sets the default value
inherit Inherit from parent

Example of this property

   <title>Example of z-index property</title>
    <style type="text/css">
<p>Result of z-index</p>
<img src="css-icon.jpg"id="a"alt="css icon" />
<p>This is the example of z-index.</p>

example of z-index property

In this chapter, you have learned about CSS z-index property with an example so now try to use this property for yourself.


Share your thought