I'm having a problem with an ASP.net website and CSS.

I've pasted my CSS code from a previous website (HTML and CSS) to have a look at it.
I've copied the basic divs etc into the masterpage.

But I'm finding that the layout isn't centered. The layout would normally be centered with a border but now it's actually positioned left. I've tried this with a few different stylesheets I had and I'm having the same problem.

Is there something special that needs to be done for ASP.net?

Any help would be appreciated!


7 Years
Discussion Span
Last Post by jbisono

ASP.NET isn't any different with CSS, because CSS is client side, ASP is server. Assuming your viewing in the same browser as the previous site was, the first thing I'd check is your css. Make sure you have all the relevant ids, classes, and tags. The best way I've found to center something, and this isn't perfect, is to give it a defined size with auto margins.


I have done that before, and never had a problem. all others styles got applied? is just that is not centered?


No, do not use the <center></center> tag, it has been deprecated and can cause unwanted behaviors in some browsers. It causes IE to switch into Qwirks mode which it tries to guess the standard by which your code is written and render accordingly, but it's quite often wrong.

It's best not to use any of the display tags in html, (<i><b><center>), because these all have been deprecated and aren't supported in all browsers. Best practice would be to place any item you'd like affected in a <span></span> or <div></div> and use CSS to adjust the display properties of it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.