Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Aligning center using margin:auto 1

Status
Not open for further replies.

mcowen

Programmer
Oct 21, 2001
134
GB
Hi,

I'm trying to align some divs centrally using...
Code:
#mycontainer
{
  margin-left:auto;
  margin-right:auto;
  width:640px;
}
and I'm getting different behaviour in HTML to XSL.
The div is aligned to the left of the page. Has anyone seen this before and know how to make XSL behave in a compliant way?

Thanks

Matt
"Success is 10% inspiration, 90% last minute changes
 
Found the reason for this....
You must specify the DOCTYPE in the HTML page passed back to the client (I am translating the XSL on the server). To do this in XSL you must put the following after the xsl:stylesheet element...
Code:
<xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" doctype-system="[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd"></xsl:output>[/URL]
which adds to the page...
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
This will then force the browser to act in a compliant way. Please note that this is the Transitional DOCTYPE for HTML. Further types are defined here....

Furthermore, there is a quirk in IE whereby if the doctype is not the first element in the page then IE is not made compliant. For example, we are using WebSpeed to pass the HTML back to the client and for some daft reason Progress has decided to append a comment to the beginning of the page which amounts to nothing but crap advertising. If you remove this comment the browser picks up the DOCTYPE properly and the page is thereby rendered correctly. Progress have obviously realised how stupid this is because they no longer do it after version 10 SP2.



Matt
"Success is 10% inspiration, 90% last minute changes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top