In xhtml <div align="center"> isn't valid. Why? and how can you center something with css. All I know of is text-align and as you probably know that centers text.
<!-- w --><a class="postlink" href="http://www.madddidley.com">www.madddidley.com</a><!-- w --> (server down) | <!-- w --><a class="postlink" href="http://www.indesignfx.comHi">www.indesignfx.comHi</a><!-- w --> -
Yup. Align is a 'deprecated' attribute in xhtml. Text-align actually does work in IE for non-text elements [oddly enough ;-)], but when using css try -
div#whatever{
margin:0 auto 0 auto;}
So that the left and right margins are automatically centered - depending on the parent/prior tag styles, etc.
Hope this helps,
ElI tried that. It didn't work in IE.Perhaps a sample? Internet Explorer, in quirks mode, well, screws up a lot of things. the align attribute is invalid, because it's using HTML to style, when that is not the purpose of HTML. There are two methods, as stated, for centering objects in CSS. text-align:center; will center all inline elements (such as text, images, and <span></span>) and margin:auto; will center all block elments (like <p></p> and <div></div>) So you can always do:
<div style="margin:auto;">
Centered Div!
</div>
If you are having issues with it in IE, make sure you have the proper DTD. IE won't even recognize the right DTD, but if it sees one, it will run CSS "properly"
<!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" xml:lang="en" lang="en" dir="ltr">IE doesn't support margin: auto; — what a surprise.
To get this to work in IE, you have to apply text-align: center; to the parent element of the element you are trying to center.
<div id="parent">
<div id="center">This is centered!</div>
</div>
<style type="text/css">
#parent {
text-align: center;
}
#center {
padding: 3px;
margin: 0 auto 0 auto;
width: 500px;
text-align: left;
border: 1px solid #000;
}
This is a fairly common technique used when centering an entire layout. The text-align: center; is applied to the BODY, and the margin: 0 auto 0 auto; ect. is applied to a wrapper DIV, which houses the rest of the code.IE in quirks mode doesn't support margin:auto; But for making my websites, I found that with a DTD, even IE will support it. At least, as of IE 6 for Windows ME.Whoa! You're right! Wow... don't I feel stupid... Oh, oh, wait, you're right. The text-align: center; is an IE 5.x (or 5.5?) fix, I believe.Internet Explorer, in quirks mode, well, screws up a lot of things.
doesnt have to be in quirks mode to screw it all up to it, it's all naturalOriginally posted by MstrBob
IE in quirks mode doesn't support margin:auto; But for making my websites, I found that with a DTD, even IE will support it. At least, as of IE 6 for Windows ME.
yea, it works for me w/ out text-align
<!-- w --><a class="postlink" href="http://www.madddidley.com">www.madddidley.com</a><!-- w --> (server down) | <!-- w --><a class="postlink" href="http://www.indesignfx.comHi">www.indesignfx.comHi</a><!-- w --> -
Yup. Align is a 'deprecated' attribute in xhtml. Text-align actually does work in IE for non-text elements [oddly enough ;-)], but when using css try -
div#whatever{
margin:0 auto 0 auto;}
So that the left and right margins are automatically centered - depending on the parent/prior tag styles, etc.
Hope this helps,
ElI tried that. It didn't work in IE.Perhaps a sample? Internet Explorer, in quirks mode, well, screws up a lot of things. the align attribute is invalid, because it's using HTML to style, when that is not the purpose of HTML. There are two methods, as stated, for centering objects in CSS. text-align:center; will center all inline elements (such as text, images, and <span></span>) and margin:auto; will center all block elments (like <p></p> and <div></div>) So you can always do:
<div style="margin:auto;">
Centered Div!
</div>
If you are having issues with it in IE, make sure you have the proper DTD. IE won't even recognize the right DTD, but if it sees one, it will run CSS "properly"
<!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" xml:lang="en" lang="en" dir="ltr">IE doesn't support margin: auto; — what a surprise.
To get this to work in IE, you have to apply text-align: center; to the parent element of the element you are trying to center.
<div id="parent">
<div id="center">This is centered!</div>
</div>
<style type="text/css">
#parent {
text-align: center;
}
#center {
padding: 3px;
margin: 0 auto 0 auto;
width: 500px;
text-align: left;
border: 1px solid #000;
}
This is a fairly common technique used when centering an entire layout. The text-align: center; is applied to the BODY, and the margin: 0 auto 0 auto; ect. is applied to a wrapper DIV, which houses the rest of the code.IE in quirks mode doesn't support margin:auto; But for making my websites, I found that with a DTD, even IE will support it. At least, as of IE 6 for Windows ME.Whoa! You're right! Wow... don't I feel stupid... Oh, oh, wait, you're right. The text-align: center; is an IE 5.x (or 5.5?) fix, I believe.Internet Explorer, in quirks mode, well, screws up a lot of things.
doesnt have to be in quirks mode to screw it all up to it, it's all naturalOriginally posted by MstrBob
IE in quirks mode doesn't support margin:auto; But for making my websites, I found that with a DTD, even IE will support it. At least, as of IE 6 for Windows ME.
yea, it works for me w/ out text-align