W3Schools.com (2024)

The z-index property specifies the stack order of an element.

The z-index Property

When elements are positioned, they can overlap other elements.

The z-index property specifies the stack order of an element (which element should be placed in front of, or behind, the others).

An element can have a positive or negative stack order:

W3Schools.com (1)

Because the image has a z-index of -1, it will be placed behind the text.

Note: z-index only works on positioned elements (position: absolute, position: relative, position: fixed, or position: sticky) and flex items (elements that are direct children of display: flex elements).

Another z-index Example

Example

Here we see that an element with greater stack order is always above an element with a lower stack order:

<html>
<head>
<style>
.container {
position: relative;
}

.black-box {
position: relative;
z-index: 1;
border: 2px solid black;
height: 100px;
margin: 30px;
}

.gray-box {
position: absolute;
z-index: 3;
background: lightgray;
height: 60px;
width: 70%;
left: 50px;
top: 50px;
}

.green-box {
position: absolute;
z-index: 2;
background: lightgreen;
width: 35%;
left: 270px;
top: -15px;
height: 100px;
}
</style>
</head>
<body>

<div class="container">
<div class="black-box">Black box</div>
<div class="gray-box">Gray box</div>
<div class="green-box">Green box</div>
</div>

</body>
</html>

Try it Yourself »

Without z-index

If two positioned elements overlap each other without a z-index specified, the element defined last in the HTML code will be shown on top.

Example

Same example as above, but here with no z-index specified:

<html>
<head>
<style>
.container {
position: relative;
}

.black-box {
position: relative;
border: 2px solid black;
height: 100px;
margin: 30px;
}

.gray-box {
position: absolute;
background: lightgray;
height: 60px;
width: 70%;
left: 50px;
top: 50px;
}

.green-box {
position: absolute;
background: lightgreen;
width: 35%;
left: 270px;
top: -15px;
height: 100px;
}
</style>
</head>
<body>

<div class="container">
<div class="black-box">Black box</div>
<div class="gray-box">Gray box</div>
<div class="green-box">Green box</div>
</div>

</body>
</html>

Try it Yourself »

CSS Property

Property Description
z-index Sets the stack order of an element

W3schools Pathfinder

Track your progress - it's free!

W3Schools.com (2024)

FAQs

Why do people avoid W3Schools? ›

Their Embedded Code Examples are Ugly

It's hard to believe a tutorial website as popular as w3schools would post code that looks like this: Not only is it poorly formatted, but it's not using syntax highlighting. And that's just the on-page code examples in their lessons.

Is W3Schools enough? ›

W3schools is a great resource for looking up how to write a specific piece of code, but it doesn't have the flow or continuity that the other courses do. Basically, as others keep mentioning, W3schools is good for syntax, but it doesn't really teach you to think like a developer.

Is W3Schools bootcamp worth it? ›

The course material, timely and aligned with industry standards, has equipped me with relevant skills for the ever-evolving tech landscape. Enrolling in the W3C Bootcamp is a decision I don't regret, and I would wholeheartedly recommend this to anyone aiming to elevate their skills in web development.

Is W3Schools completely free? ›

Both My Learning and W3Schools Public Profile are completely free of charge, however there are available upgrade plans that can enhance your learning experience. Where can I find My Learning? You can access your My Learning profile through the upper right corner on any W3Schools page.

Can you trust W3Schools? ›

W3Schools Certificates are trusted by the top companies and institutions worldwide. We are the largest web developer learning site in the world.

How credible is W3Schools? ›

W3Schools is Trusted by Top Companies

W3Schools has over two decades of experience with teaching coding online. Our certificates are recognized and valued by companies looking to employ skilled developers.

Which is better W3Schools or codecademy? ›

Of the two, Codecademy has a simpler structure. You can easily find the topic you want and start learning. Its fixed pricing plans are also easier to understand. In addition, the biggest issue with W3Schools is the ads that keep popping up as you learn.

Is sololearn better than W3Schools? ›

Neither are necessarily better than the other because they both show their curriculum in different ways. I think Sololearn is better for experimentation and First-time learning while w3 schools is better for reference.

Who is behind W3Schools? ›

It is run by Refsnes Data in Norway. It has an online text editor called TryIt Editor, and readers can edit examples and run the code in a test environment.

Is W3 certification worth it? ›

Please, do not spend your own money on these certifications: they are almost worthless. I say almost worthless because, of course, if your company wants to pay for them and sees value in them then by all means … get that certification.

Is W3Schools enough for SQL? ›

W3schools is the complete opposite: lots of clearly structured lessons with clear examples and straightforward explanations. Perhaps that's the best resource to learn SQL currently available.

Do you get a certificate from W3Schools? ›

W3Schools offers certification exams in various software development topics. Pass a timed certification exam at an intermediate level or higher and get a Certification of Completion. You have up to 3 attempts for each exam. Exams adjust in difficulty based on your answers, making them easier or harder as you go.

Is W3Schools good enough? ›

So,for starters and some easy fast crossreference,it is very good place. But once you get into some more advanced stuff,w3school will be limit with info and you will need to search elsewhere, like stackoverflow or even better,the language documentation itself.

How does w3school make money? ›

Through ads : through ads alone they will earn alot in w3schools. They would earn nearly 1–2lacks per day in ads alone. Through donation:. Many people who completed their courses in w3schools, after few years , they would donate some money for the growth of the site .

Which country owns W3Schools? ›

W3Schools was originally created in 1998, by Refsnes Data, a Norwegian software development and consulting company.

Is W3Schools good for kids? ›

W3Schools is a free educational website for learning coding online that's great for more advanced coders. For students in middle school and high school, W3Schools is a great resource for coding tutorials in multiple programming languages: HTML, CSS, JavaScript, Python, SQL, and more.

How popular is W3Schools? ›

The largest web developer site on the internet.
  • 3 billion pages displayed each year.
  • 70 million visitors each month.

Top Articles
Uh Hospitals Follow My Health
Bfri Forum
Navicent Human Resources Phone Number
Ohio Houses With Land for Sale - 1,591 Properties
Hotels Near 625 Smith Avenue Nashville Tn 37203
El Paso Pet Craigslist
Tabc On The Fly Final Exam Answers
Unblocked Games Premium Worlds Hardest Game
Jailbase Orlando
Lifebridge Healthstream
Google Sites Classroom 6X
Coffman Memorial Union | U of M Bookstores
Co Parts Mn
According To The Wall Street Journal Weegy
How to watch free movies online
Culvers Tartar Sauce
Fairy Liquid Near Me
Marvon McCray Update: Did He Pass Away Or Is He Still Alive?
Pokemon Unbound Shiny Stone Location
Riversweeps Admin Login
Panola County Busted Newspaper
Bento - A link in bio, but rich and beautiful.
6892697335
Costco Jobs San Diego
Expression&nbsp;Home&nbsp;XP-452 | Grand public | Imprimantes jet d'encre | Imprimantes | Produits | Epson France
Chelsea Hardie Leaked
Log in to your MyChart account
Spirited Showtimes Near Marcus Twin Creek Cinema
Page 2383 – Christianity Today
Calculator Souo
About | Swan Medical Group
Etowah County Sheriff Dept
Dynavax Technologies Corp (DVAX)
Wattengel Funeral Home Meadow Drive
Mckinley rugzak - Mode accessoires kopen? Ruime keuze
Labyrinth enchantment | PoE Wiki
Orion Nebula: Facts about Earth’s nearest stellar nursery
Shane Gillis’s Fall and Rise
Lake Andes Buy Sell Trade
Charli D'amelio Bj
Arnesons Webcam
Pink Runtz Strain, The Ultimate Guide
Booknet.com Contract Marriage 2
Searsport Maine Tide Chart
Jane Powell, MGM musical star of 'Seven Brides for Seven Brothers,' 'Royal Wedding,' dead at 92
Tito Jackson, member of beloved pop group the Jackson 5, dies at 70
Zits Comic Arcamax
Craigslist Psl
Craigslist Indpls Free
Estes4Me Payroll
Taterz Salad
Latest Posts
Article information

Author: Nathanael Baumbach

Last Updated:

Views: 6109

Rating: 4.4 / 5 (75 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Nathanael Baumbach

Birthday: 1998-12-02

Address: Apt. 829 751 Glover View, West Orlando, IN 22436

Phone: +901025288581

Job: Internal IT Coordinator

Hobby: Gunsmithing, Motor sports, Flying, Skiing, Hooping, Lego building, Ice skating

Introduction: My name is Nathanael Baumbach, I am a fantastic, nice, victorious, brave, healthy, cute, glorious person who loves writing and wants to share my knowledge and understanding with you.