Skip to content
Home Blog Web Design A look into CSS z-index property

A look into CSS z-index property

  • Web Design
Blueprint Digital
Blueprint Digital

Insights from the Blueprint Digital team.

I love CSS, as you can tell from my blog posts on it such as font sizes in CSS and CSS box models. As a web developer focusing on front-end development at Blueprint, CSS, along with making custom WordPress themes, is my favorite part of development. Some CSS properties are used more often than others. Today, I will be writing about z-index, a very important property in CSS.

Z-index

In CSS, z-index property defines the stacking order for HTML elements on a page. The higher the number for z-index, the higher an element will appear in the stack. Z-index can be either positive or negative. That means an element with a high positive number (ex. 9999) will appear “on top” of other elements that have a lower z-index number. An element with a low negative number (ex. -1) will appear “behind” elements that have a higher z-index value.

Usually, HTML elements on a page have a natural stacking order, and the z-index is usually assigned by the order of appearance in the document flow. There are many factors that affect z-index, but usually an element nested in another element will have a higher z-index value.

To define the z-index property of an element in CSS, you must define the position of the element as absolute, fixed, or relative! This is very important to remember. If you assign a z-index value without defining the position, the z-index will not work because the position will be set to the default (position: static), which renders elements in the order they appear (document flow).

Z-index in Internet Explorer

One of the things that give web developers trouble sometimes is compatibility issues with Internet Explorer, particularly the older browsers 6 and 7. That is because IE6/7 have a lot of inconsistencies that do not follow “standard” CSS. Z-index is one of them. In IE 6 and 7, z-index is not defined by the document flow but by an element’s relation to other elements on the page. For example, let’s say you have the following code:

<ul class="nav">
	<li><a href="#">Link</a></li>
	<li><a href="#">Link</a>
		<ul class="subnav">
			<li><a href="#">Link</a></li>
			<li><a href="#">Link</a></li>
		</ul>
	</li>
	<li><a href="#">Link</a></li>
</ul>

<div class="content">
	Content
</div>

Let’s say the CSS is like this:

.nav {
	position: relative;
	z-index: 1;
}

.subnav {
	position: absolute;
	z-index: 9999;
}

.content {
	position: relative;
	z-index: 200;
}

In old IE browsers, the dropdown menu will be covered by the content because the parent element (<ul>) has a small z-index value compared to other elements. If you set the z-index value of the ul element to be higher than the content, the dropdown menu will appear on top of the content.

Conclusion

Z-index can be a tricky concept, especially in older Internet Explorer browsers. However, understanding the document flow and how z-index operates could make the development process easier.

Ready to Dominate Online and Grow Your Business?

Schedule time to connect with Blueprint about your online goals, or request a free review of marketing campaigns.

Related Posts

Lead Scoring for B2B: How to Decide Which Leads Your Sales Team Chases

Lead Scoring for B2B: How to Decide Which Leads Your Sales Team Chases

Every marketing team has handed sales a list of leads that went nowhere. After a few of those lists, sales stops trusting them, works its own referrals instead, and the two teams settle into a standing argument about lead quality. Underneath the argument is a simpler problem: nobody has written down what a good lead[...]
Why Your Blog Is Stealing Rankings From Your Service Page (and How to Stop It)

Why Your Blog Is Stealing Rankings From Your Service Page (and How to Stop It)

You publish a blog to support a service page, expecting it to bring in readers and pass authority down to the page that closes business. Months later the blog is outranking the service page for the term that drives leads, and the service page has slipped. The supporting piece has turned into a competitor, a[...]
Why B2B Online Marketing Looks Different in 2026

Why B2B Online Marketing Looks Different in 2026

By 2026, the B2B buyer has done most of the work before a vendor ever enters the conversation. The decision takes shape across Google, AI assistants, LinkedIn, and peer reviews, and it rarely rests with one person: a committee of five or more stakeholders now builds the shortlist. B2B online marketing has changed to match[...]
Previous
Next

Partner with BLUEPRINT to reach your online goals, grow your business and reshape your story.

Get in touch with BLUEPRINT

Reach out to request a discovery call, a free campaign review, or for all other inquiries.

Subscribe to our newsletter