473,503 Members | 1,300 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Centering Divisions

8 New Member
I have a question on how to center a < div > on a page. (you can see my code at http://home.satx.rr.com/almain/Test/Default.aspx and http://home.satx.rr.com/almain/Test/AEHcss.css

I've noticed a lot of websites are starting to go to this (i.e. cnn.com and nfl.com) I like it because I can put information in a narrower space and it makes the site look fuller. (I understand this is probably poor webdesign, but I'm just learning).

I've also looked through the forums and I saw an answer to the same question asked back in 2005 but it quickly transformed into a mud slinging contest and went off subject. The answer that was provided doesn't seem to work for me.

I also would like to know how, with or without using < div > to center a table.
Aug 20 '08 #1
6 1437
David Laakso
397 Recognized Expert Contributor
Expand|Select|Wrap|Line Numbers
  1. #foo {width:whatever; margin: 0 auto;}
  2.  
Validate your site.
Aug 20 '08 #2
AllenH
8 New Member
Please check out my code. I did your suggestion but it still buts the information to the left.
Aug 21 '08 #3
David Laakso
397 Recognized Expert Contributor
As previousley mentioned, validate your markup [1]. And -- as previously mentioned -- a width, in addition to margin: 0 auto; , needs to be assigned to the division you wish to be centered.

[1]
w3c markup validation service
Aug 21 '08 #4
AllenH
8 New Member
My CSS checked good. http://jigsaw.w3.org/css-validator/v...t%2FAEHcss.css The only problems I have in my actual html is it doesn't like the .aspx format (C#). I've tried the same thing on another website of mine that isn't run in C# and it does the same thing.

My CSS says:
Expand|Select|Wrap|Line Numbers
  1. #header    
  2. {
  3.     border-style: solid;
  4.     border-color: Navy;
  5.     background: white;
  6.     width:  965px;
  7.     margin: 0 auto;
  8.     }
  9.  
My code says
Expand|Select|Wrap|Line Numbers
  1.     <div id="header">
  2.   Items in div
  3.     </div>
Aug 23 '08 #5
David Laakso
397 Recognized Expert Contributor
The prologue above the doctype (.aspx format (C#)) is putting IE/6 in quirksmode (making it behave as though it were IE5.5) and, compliant browsers in quirksmode-- in the sense they are at "less than" standards mode (someone correct me if wrong) . I do not know how one should call .aspx format (C#) in order for this not to happen.

And the doctype you are using is invalid (malformed). In other words, the doctype is not found [1], among other errors. All in all this is not a good situation...

[1]
invalid markup
Aug 23 '08 #6
AllenH
8 New Member
Hm, good call. I didn't realize that the C# stuff would have affected the code like that.

Made it straight xhtml and it worked like a charm. Thanks!
Aug 27 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1234
by: Dennis M. Marks | last post by:
Please ignore all previous postings from me for the past couple of days. All has been solved except for the following. I have three divisions that I am having trouble positioning. What works in...
11
15031
by: Jeff Thies | last post by:
I have a series of blocks that are float left that I need centered on the page. <div class="center" align="center"> <div style="width: 100 px;float: left">thumbnail 1</div> <div style="width:...
6
1936
by: Fran¨ois de Dardel | last post by:
http://mapage.noos.fr/dardelf3/tintin/page3bits.html Can I center the series of thumbnails horizontally in the pages _and_ keep the "elastic arrangement" where the number of thumbnails adapts to...
3
7344
by: Jonah Bishop | last post by:
I have a puzzling problem with centering text, and I'm hoping that someone here can help me out. First of all, let me state that I am using XHTML 1.0 Strict and CSS for all layout purposes (no...
2
2226
by: Ryan W Sims | last post by:
I'm having trouble with centering in IE... http://www.ryanwsims.com/koh/ The image should center over the text. It does in Firebird, but not in IE for some reason. If you look at ...
15
13480
by: red | last post by:
How do I center two side by side divs ? I've been writing css pages for a while but there's one thing tha still eludes me. I can center a div with margin auto. I can place two divs side by side...
6
2027
by: Axel Siebenwirth | last post by:
Hi, as described at http://www.quirksmode.org/css/centering.html, I try to do to centering with my site. I did exactly as told on that page but it only seems to center horizontally. My site...
3
4189
by: John Pote | last post by:
1. Horizontal centering a <divin browser window. The current trend seems to be to place page content in a fixed width area in the middle of the browser window. How is this achieved? If I use a...
5
4808
by: Markus Ernst | last post by:
Hello This is a test example: http://www.markusernst.ch/anthracite/ http://www.markusernst.ch/anthracite/living_divani.html After googling and experimenting for several hours, I ended up...
1
2271
by: =?Utf-8?B?ZnJhbmt5?= | last post by:
Hello, I've created a table that has two rows that are span across three columns. The third row has three columns, each with an image. The last row is also span accross three columns. The span...
0
7089
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7463
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5581
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5017
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1515
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
738
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.