views:

31

answers:

1

Hello colleagues, I am facing a very strange issue because of which when i do not add the below line to the html the layers(z-index) is not working.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"; "_http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

Please let me know if you are aware of the issue and how to get layers working without adding this tag.

Best Regards, Keshav

A: 

Modern versions of IE (7+) have different rendering engines, and choose their rendering engine based on the user's preferences and the page's doctype. So your problem is probably that whatever default rendering engine IE is using when you test your page (probably a compatibility mode) either has a rendering bug or exposes a bug in your mark-up that causes the z-index to not render properly. When you add the doctype, IE changes its rendering engine and the bug in the old rendering engine or your code disappears, so your z-index renders just fine.

There are two ways to fix this:

  1. You can try to tweak your mark-up so that the z-index is rendered correctly in both rendering engines. This might be a lot of work.
  2. You can make sure you always specify a doctype. This is a best practice, and you should always do it anyways.
Dan M