473,382 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

center align a page

I've got a page with content that I want aligned in the center, with
equal margins on both sides (text, left aligned).

It seems to me that this is a complex thing to get right on most
browsers and required putting the page in a div and then body:
textalign: center
and a few other hacks

There was a site that explained this rather well but I can't seem to
google it up. Where is that?

The page in question is fixed width and image heavy (photos) so it
escapes the normally very good reasons to not center align.

Cheers,
Jeff
Aug 5 '05 #1
7 5255
Jeff Thies wrote:
I've got a page with content that I want aligned in the center, with
equal margins on both sides (text, left aligned).

div.body { margin-left: auto; margin-right: auto; }
No hacks needed. Even works in IE6.

--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Aug 5 '05 #2
Jeff Thies <je**@spamalanadingong.com> wrote:
I've got a page with content that I want aligned in the center, with
equal margins on both sides (text, left aligned).

There was a site that explained this rather well but I can't seem to
google it up. Where is that?
http://dorward.me.uk/www/centre/

Btw, David: you're a very naughty boy for using browser sniffing.
The page in question is fixed width and image heavy (photos) so it
escapes the normally very good reasons to not center align.


It shouldn't be fixed width, thus there should be no point in centering
it.

--
Spartanicus
Aug 5 '05 #3
Els
Jim Moe wrote:
Jeff Thies wrote:
I've got a page with content that I want aligned in the center, with
equal margins on both sides (text, left aligned).

div.body { margin-left: auto; margin-right: auto; }
No hacks needed. Even works in IE6.


If you want it to work in WinIE5 too:
http://locusmeus.com/html-css/centeringpage.html

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Aug 5 '05 #4
Spartanicus wrote:
Btw, David: you're a very naughty boy for using browser sniffing.


I didn't write the script, and when I started using it my JS-foo wasn't good
enough to recognise the problem. I'll probably rewrite it one day.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Aug 5 '05 #5
David Dorward <do*****@yahoo.com> wrote:
Btw, David: you're a very naughty boy for using browser sniffing.


I didn't write the script, and when I started using it my JS-foo wasn't good
enough to recognise the problem. I'll probably rewrite it one day.


Server side JS? (I have client side JS disabled)

But the problem isn't the accuracy since browser sniffing is inaccurate
by definition.

--
Spartanicus
Aug 5 '05 #6
Spartanicus wrote:
Btw, David: you're a very naughty boy for using browser sniffing.
I didn't write the script, and when I started using it my JS-foo wasn't
good enough to recognise the problem. I'll probably rewrite it one day.
Server side JS? (I have client side JS disabled)
No. Client-side JS. Its a hack to fake support for <abbr> in MSIE.
But the problem isn't the accuracy since browser sniffing is inaccurate
by definition.


Rewrite it so that it does object detection (or uses conditional comments).

I think perhaps we are talking at crosspurposes here. What browser sniffing
do you think I use?
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Aug 5 '05 #7
David Dorward <do*****@yahoo.com> wrote:
I think perhaps we are talking at crosspurposes here. What browser sniffing
do you think I use?


Apologies, I thought you were using server side http UA header sniffing
to conditionally serve or deny CSS. I got unstyled content with my
standard setup, this is usually down to my spoofed UA header, but on
closer inspection one of my web page filters is doing unexpected things.

Off to check my filters.

--
Spartanicus
Aug 5 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: PayPal | last post by:
<HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft DHTML Editing Control"> <TITLE></TITLE> </HEAD> <BODY> <STYLE type=text/css> ..dummy {} BODY, TD {font-family:...
3
by: VB Programmer | last post by:
I cant 'align center' a text box. First of all, all the justifications (left, center, right) on the toolbar are dimmed. Why? Also, when I try to do it through HTML (wrapping the control in a...
7
by: ALI-R | last post by:
Hi All, I have two user controls (header and footer) ,,which I've placed in an HTML Table in a page.I set the **align="center"** in the table and the table still is on the left side of the page...
4
by: Joey | last post by:
Does anyone know how to center this sample webpage in Firefox? If so, will you provide the example as it applies to this sample webpage? I have read numerous posts and articles on how to center...
2
by: Eric Lindsay | last post by:
If I want to have the middle of an image vertically aligned with the middle of a heading (or several lines of heading), is there some particular way people would recommend? vertical-align: center...
1
by: judacris | last post by:
I've seen the threads here about molding 2 divs in a centered fashion. but I can't seem to solve this thing. my blogger blog is functioning well on my site for now, but the blog feed (left) and...
24
by: GloStix | last post by:
I'm trying to center this banner, it's in a div that has the same width so it's not exactly "centering" but it's screwed up, It works in safari but in Firefox it's messed up. I uploaded a Video to...
2
by: yangtono | last post by:
Hi, I am creating a table to list some data. The table is using a sorting and highlight function that I found from the net. I can't attach image here, basically html will wrap the heading,...
14
by: gaijinco | last post by:
I was a hobbist web coder for years but I had to sidestep for a while. Now I'm trying to return to it and I'm trying to clarify how am I supposed to do somethings with CSS v.s. HTML and I'm...
13
by: Stevo | last post by:
I've found that for IE6+, if you add the property text-align:center to a DIV, then *anything* inside it gets centered. That can be a table, an object/embed, another DIV, an image, or some text. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.