Hello there
I do not know what I am doing wrong but I do not get to center this site www.metatradersoftware.com completely. Although it has moved a bit to the right side since I put the wrapper, it is still staying quite on the left part of the screen. The code looks like this:

#wrap       
{ 
	  position: relative;
	  width:760px; 
          margin-left:auto;
	  margin-right:auto;
}
<body>
<div id="wrap">  
....
</div>
</body>
</html>

I would appreciate any ideas to solve this issue, because as far as I seen, this is the standar way of centering a website with css.
Look for your replies.
Thanks in advance

Recommended Answers

All 11 Replies

thats the proper way of centering.. that should work... just remove the position:relative
however, that will work for browsers like FF, Opera, etc.... but not in IE

to center divs in IE just add text-align:center;

like so:

#wrap {
text-align:center;
width:760px;
margin:auto;
}

Regards

shocks forgive me.... my first post was wrong...

heres the correct one...

body{text-align:center;}

#wrap {;
width:760px;
margin:auto;
}

use this code

#wrap       
{ 
	  position: relative;
	  width:760px; 
                 margin:0px auto;

}

Hello there
I do not know what I am doing wrong but I do not get to center this site www.metatradersoftware.com completely. Although it has moved a bit to the right side since I put the wrapper, it is still staying quite on the left part of the screen. The code looks like this:

#wrap       
{ 
	  position: relative;
	  width:760px; 
          margin-left:auto;
	  margin-right:auto;
}
<body>
<div id="wrap">  
....
</div>
</body>
</html>

I would appreciate any ideas to solve this issue, because as far as I seen, this is the standar way of centering a website with css.
Look for your replies.
Thanks in advance

0px is an invalid style. Use 0 for any zero value, without units.

<DIV style="position: relative;  width:760px; margin-left: 132; margin-right: 132; border: 1px solid red">
Center Text</DIV>

Also note that using uppercase letters in tag names is deprecated. This puts the browser into quirks mode.

@MidiMagic can you please give me a reference where you found uppercase tags are deprecated. actually the tag attribute should be in lowercase that is all what I know..

http://www.w3.org/TR/xhtml1

Note that this is not so much that the uppercase versions of tags are deprecated as it is that the new browsers are case-sensitive, and the tags are defined to be lowercase. But the effect is the same.

Thanks MidiMagic for the reference link. I 've visited the link and found all the HTML elements are writtenin lowercase and I do agree following this rule but I donot find that Uppercase elements are deprecated.

Thanks again

http://www.w3.org/TR/xhtml1

Note that this is not so much that the uppercase versions of tags are deprecated as it is that the new browsers are case-sensitive, and the tags are defined to be lowercase. But the effect is the same.

I have to agree with midimagic though I would have not used the word deprecated I would have used the word incorrect coding because xhtml does not support uppercase except for the doctype that has to be in uppercase. I would suggest going to www.w3schools.com they are a great source of information for coding!

Uppercase characters for tags, styles, and attributes are definitely deprecated in xhtml. But some browsers are failing to recognize some styles and attributes in html.

There is still the incompatibility between IE and other browsers that results when you put size styles (width, height) in the same tag or style that has nonzero surrounding styles (margin, border, padding). IE nexts the surrounding styles inside the sizes, the other browsers nest the sizes inside the surrounding styles.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.