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!


Recommended Answers

All 6 Replies

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?

How are you attempting to center it? Could you post a code example?

Use <center></center>tag between body tag.

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.

Use the technique that Fortinbra said!!! using auto margins....

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.