473,657 Members | 2,430 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.co m/almain/Test/Default.aspx and http://home.satx.rr.co m/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 1455
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
1249
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 IE does not work in Netscape. I have removed all top and left positioning from the css. If you look at my current home page you will see 3 divisions on the bottom. There is a calendar (calendar), calendar controls (controls), and a counter...
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: 100 px;float: left">thumbnail 2</div> <div style="width: 100 px;float: left">thumbnail 3</div> </div>
6
1943
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 the width of the screen. Franēois de Dardel http:/mapage.noos.fr/dardelf Faber est suae quisque fortunae Remove fourteen to reply
3
7352
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 tables). My website consists of a few, simple parts: a "container" DIV which is centered and 750 pixels wide, a "sidebar" DIV which can be found along the left side of the container, and a "content" DIV which fills up what's left of the right part of...
2
2235
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 http://www.ryanwsims.com/sd.php everything's fine (i.e. centered)
15
13495
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 with float. But I can't center two side by side divs. If I float them and give them auto margins, the auto margins are ignored. If I wrap the two floated divs in another div, the two divs have no
6
2032
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 is at http://www.up-2-d8.de/menu.html Can you please take a look and see whether you can find anything I am doing wrong?!
3
4198
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 top level <divthen I can place it with CSS attribute 'left:', but this is a fixed offset. Is it possible to have a <divcentered in the browser window? 2. Verticle centering in <div>
5
4815
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 doing this demo with tables. The main problems are the vertical centering of the info area, and of the text inside the squares.
1
2277
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 rows are centering their data. however, the row with three columns, each with images (myimages1-3) are not centering with the rest of the table. Any idea why? Thanks in advance!
0
8829
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8734
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8508
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7341
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5633
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4164
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
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 we have to send another system
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.