2

At present i am using ie9 to render my web pages. While using the 'margin: 0 auto' css property for one of my requirements, it did not work.So i surfed a lot and found the reason, i did not specify the doctype in order to turn off the quirks mode. So that i added a doctype which was specified in the link. as a result my web page is not seems to be loading as it is. It is omitting some css and scripts [jquery] that was binded with it.

when ever i try to load the webpage by removing the doctype, it is displaying all the contents normally, but margin: 0 auto not seems to be working..

By the way,This link states that jquery will responds differently to quirks mode turned off and on.so i tried to change my scripts too. but same result occured.

I am very confused at this stage. Any clues.?

EDIT:

HTML:

<html>
<head>
<title>Rajaprabhu</title>
<link rel="stylesheet" type="text/css" href="css/PrabhuCss.css">
</head>

<body>

 <div id="DivMenu">
   <div id="DivLogo">R</div>
 </div>

 <div id="DivMain">
   <div id="DivHeader">
   </div>
   <div id="DivContent">
     <div id="DivSlider">
       <div id="DivHome">        
       </div>
       <div id="DivSkills">
       </div>
     </div>
   </div>
   <div id="DivFooter">
   </div>
 </div>

</body>

</html>

CSS: [PrabhuCss.css]

#DivMain
{
position: relative;
width:100%;
height:100%;
z-index:1;
}

#DivFooter
{
position:absolute;
width:100%;
height:5%;
bottom:0%;
left:0%;
background-image: url('../Images/ImgHeaderFooter.jpg');
z-index:5;
border-top: 2px solid #2F2E2E;   
}

#DivHeader
{
position:absolute;
width:100%;
height:10%;
top:0%;
left:0%;
background-image: url('../Images/ImgHeaderFooter.jpg');
z-index:6;
border-bottom: 2px solid #2F2E2E;
}

#DivMenu
{
position:absolute;
border-radius: 999px;
background: #ccc;
border: 2px solid #2F2E2E;
cursor: pointer;
z-index:7;
text-align:center;
width: 4%;
height: 8%;
left: 48%;
top: 6%;
}

#DivLogo
{
font-family: 'Wendy One', sans-serif;
font-size:35px;
position:relative;
top:50%;
margin-top: -18px;
}

#DivContent
{
position:relative;
width:100%;
height:85.02%;
top:10%;
left:0%;
z-index:2;
overflow: hidden;
}

#DivSlider
{
position:absolute;
width:100%;
height:100%;
z-index:3;
}

#DivHome
{
width:100%;
height:50%;
z-index:4;
background-image: url('../Images/ImgBackground.jpg')
}

#DivSkills
{
width:100%;
height:50%;
z-index:4;
background-image: url('../Images/ImgBackground.jpg')
}

body
{
margin:0;
padding:0;
border: 0;
overflow:hidden;
}

If i use <!doctype html> in the top of my Html, the page is not displaying properly.
But with out that there wont be any problems in rendering.

Community
  • 1
  • 1
Rajaprabhu Aravindasamy
  • 63,064
  • 13
  • 90
  • 119

3 Answers3

0

You might have included the wrong doctype.

The doctype for modern standards is as simple as <!doctype html> to be used at the beginning of the page.

eg:

<!doctype html>
<html>
    <head></head>
    <body></body>
</html>
  • "If i use ` ` in the top of my Html ..." – John Dvorak Jan 01 '13 at 10:59
  • Since the old days of quirk mode, there have been major changes in the browsers for the implementation of CSS "position" style. You should probably start using `position: fixed` instead of `position: absolute` ... I believe you will need to rewrite a lot many things in the mentioned code. – webextensions.org Jan 01 '13 at 11:44
0

I don't see anything in your CSS that has that rule (margin: 0 auto;), but as a rule auto only works for margins when the element has a defined width.

Also, you really should be specifying a character set. The recommendation is to use UTF-8, for the most part:

<!doctype html>
<head>
    <meta charset="utf-8" />
    <!-- everything else... -->

This should be the first element inside the <head> element.

Tieson T.
  • 20,030
  • 4
  • 69
  • 86
0

Solution Found,

The child element which is relative to its parent wont get any height untill we assign any fixed height to its parent.So that, in my case DivMenu is relative to body and html tags, but i did not specify any height for it. In Quirks mode, the rendering engine just left the above rule and rendered the page,But in other modes with doctypes (Ex: <!DOCTYPE html>) specified, it cosidered that rule. That is the problem. That's why my page got collapsed.

Live Version: Before - After

CSS:

html,body          //Html tag added
{
height:100%;       //Added this
width:100%;        //Added this
margin:0;
padding:0;
border: 0;
overflow:hidden;
}
Rajaprabhu Aravindasamy
  • 63,064
  • 13
  • 90
  • 119