HTML | DOM Style zIndex Property
The Style zIndex property is used for set or return the stack order of a positioned element. The element which has a lower stack order will be behind of another element with higher stack order.
For example, the element with stack order(1) will be in front of the element with stack order(0).
The Style zIndex property is generally used when the user wants to create overlapping elements.
- To get the property:
- To set the property:
object.style.zIndex = "auto|number|initial|inherit"
- auto: It is used to let the browser determine the stack order of the element.
- number: It uses an integer that defines the stack order of the element.
- initial: It is used to set the default value.
- inherit: It is used to inherit property from its parent.
Below program illustrates the Style zIndex property :
Example: Changing the stack order of an <img> element.
- Before clicking the button:
- After double clicking on the button:
Supported Browsers: The browser supported by HTML | DOM Style zIndex Property are listed below:
- Google Chrome
- Internet Explorer
- Apple Safari
Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML course.