?
Solved

Z-Index Deprecated in xhtml?

Posted on 2009-04-03
3
Medium Priority
?
655 Views
Last Modified: 2013-11-19
Why doesn't the z-index seem to work in the following example?  The text "Layer 2" text doesn't show up on top of the "Layer 1" text unless I remove the DOCTYPE declaration at the top of the page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang= "en">
<head>
</head>
 
<body>
<div style="position:relative; font-size:50px; z-index:3;">LAYER 1</div>
<div style="position:relative; top:-50; left:5; color:red; font-size:80px; z-index:40">LAYER 2</div>
</body>
 
</html>

Open in new window

0
Comment
Question by:eh1160
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 21

Accepted Solution

by:
Julian Matz earned 200 total points
ID: 24066033
Hi! No, it's not deprecated. You just had the properties for "top" and "left" wrong by ommiting the unit (e.g. px). The following should work:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang= "en">
<head>
</head>
 
<body>
<div style="position:relative; font-size:50px; z-index:3;">LAYER 1</div>
<div style="position:relative; top:-50px; left:5px; color:red; font-size:80px; z-index:40">LAYER 2</div>
</body>
 
</html>

Open in new window

0
 

Author Closing Comment

by:eh1160
ID: 31566506
Awesome...thanks for the quick solution!  (And duh...I wish I figured that out on my own!)
0
 
LVL 21

Expert Comment

by:Julian Matz
ID: 24067865
No problem. Glad I could help. Sometimes it takes an extra pair of eyes to spot something as simple as this - especially if you've been looking at the same code for a long time :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question