By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,785 Members | 1,079 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,785 IT Pros & Developers. It's quick & easy.

Can't get text to center

P: n/a
Hi,

I am trying to create a simple two column layout, with a heading centred in the
right column. I don't want to specify the size of the right column, but I am
limiting the left column to 200 pixels in width.

Is this possible?

Thanks for any help.
--
Ben Thomas
Jul 20 '05 #1
Share this Question
Share on Google+
30 Replies


P: n/a
BenOne© <no**@m.thanks.mate> wrote:
I am trying to create a simple two column layout, with a heading centred in the
right column. I don't want to specify the size of the right column, but I am
limiting the left column to 200 pixels in width.

Is this possible?


CSS table (not supported by IE).

--
Spartanicus
Jul 20 '05 #2

P: n/a
BenOne© <no**@m.thanks.mate> wrote:
I am trying to create a simple two column layout, with a heading centred in the
right column. I don't want to specify the size of the right column, but I am
limiting the left column to 200 pixels in width.

Is this possible?


CSS table (not supported by IE).

--
Spartanicus
Jul 20 '05 #3

P: n/a
On Tue, 13 Apr 2004 23:15:10 GMT, BenOne© <no**@m.thanks.mate> wrote:
Hi,

I am trying to create a simple two column layout, with a heading centred in the
right column. I don't want to specify the size of the right column, but I am
limiting the left column to 200 pixels in width.

Is this possible?

Thanks for any help.


Is there any reason for not using <center><h2> header </h2></center> ? Urological?

.... i meant "theo"

Mason C
Jul 20 '05 #4

P: n/a
On Tue, 13 Apr 2004 23:15:10 GMT, BenOne© <no**@m.thanks.mate> wrote:
Hi,

I am trying to create a simple two column layout, with a heading centred in the
right column. I don't want to specify the size of the right column, but I am
limiting the left column to 200 pixels in width.

Is this possible?

Thanks for any help.


Is there any reason for not using <center><h2> header </h2></center> ? Urological?

.... i meant "theo"

Mason C
Jul 20 '05 #5

P: n/a
BenOne© wrote:
I am trying to create a simple two column layout, with a heading centred
in the right column. I don't want to specify the size of the right column,
but I am limiting the left column to 200 pixels in width.


#sidebar {
width: 200px;
position: absolute; top: 0; left: 0;
}

#content {
margin-left: 200px;
}

#content h1 { text-align: center; }

(Most margins and padding have not been accounted for, the above will cause
overlaps, however it does show a technique that should work)

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Jul 20 '05 #6

P: n/a
BenOne© wrote:
I am trying to create a simple two column layout, with a heading centred
in the right column. I don't want to specify the size of the right column,
but I am limiting the left column to 200 pixels in width.


#sidebar {
width: 200px;
position: absolute; top: 0; left: 0;
}

#content {
margin-left: 200px;
}

#content h1 { text-align: center; }

(Most margins and padding have not been accounted for, the above will cause
overlaps, however it does show a technique that should work)

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Jul 20 '05 #7

P: n/a
On Wed, 14 Apr 2004 05:35:20 GMT, MasonC <ma****@ix.netcom.xyz.com> wrote:

Is there any reason for not using <center><h2> header </h2></center> ?


<center> is deprecated so you'd have to use transitional markup. The above
is exactly equivalent to <h2 align=center>header</h2> but again the align
attribute is deprecated.

There's currently no valid way to center in HTML strict unless you use CSS.
Jul 20 '05 #8

P: n/a
On Wed, 14 Apr 2004 05:35:20 GMT, MasonC <ma****@ix.netcom.xyz.com> wrote:

Is there any reason for not using <center><h2> header </h2></center> ?


<center> is deprecated so you'd have to use transitional markup. The above
is exactly equivalent to <h2 align=center>header</h2> but again the align
attribute is deprecated.

There's currently no valid way to center in HTML strict unless you use CSS.
Jul 20 '05 #9

P: n/a
/BenOne©/:
I am trying to create a simple two column layout, with a heading centred
in the right column. I don't want to specify the size of the right
column, but I am limiting the left column to 200 pixels in width.


Since you're going to put text content in the left column (most
probably) it is wiser to choose 'em' units to specify its width. You
may calculate the 'em' value while you divide 200px on the
calculated pixel font-size you got for that element.

--
Stanimir
Jul 20 '05 #10

P: n/a
/BenOne©/:
I am trying to create a simple two column layout, with a heading centred
in the right column. I don't want to specify the size of the right
column, but I am limiting the left column to 200 pixels in width.


Since you're going to put text content in the left column (most
probably) it is wiser to choose 'em' units to specify its width. You
may calculate the 'em' value while you divide 200px on the
calculated pixel font-size you got for that element.

--
Stanimir
Jul 20 '05 #11

P: n/a
On Wed, 14 Apr 2004, Neal wrote:
On Wed, 14 Apr 2004 05:35:20 GMT, MasonC <ma****@ix.netcom.xyz.com> wrote:
Is there any reason for not using <center><h2> header </h2></center> ?

Is there -any- reason for wanting to? This isn't the Mosaic
Communications Corporation's pseudo-DTP language, after all! Things
have moved on since then.
There's currently no valid way to center in HTML strict unless you use CSS.


Expecting there to be so would seem to be to misunderstand the
intention of "strict" HTML, right?
Jul 20 '05 #12

P: n/a
On Wed, 14 Apr 2004, Neal wrote:
On Wed, 14 Apr 2004 05:35:20 GMT, MasonC <ma****@ix.netcom.xyz.com> wrote:
Is there any reason for not using <center><h2> header </h2></center> ?

Is there -any- reason for wanting to? This isn't the Mosaic
Communications Corporation's pseudo-DTP language, after all! Things
have moved on since then.
There's currently no valid way to center in HTML strict unless you use CSS.


Expecting there to be so would seem to be to misunderstand the
intention of "strict" HTML, right?
Jul 20 '05 #13

P: n/a
On Tue, 13 Apr 2004 23:15:10 GMT, BenOne© <no**@m.thanks.mate> wrote:
Hi,

I am trying to create a simple two column layout, with a heading centred in the
right column. I don't want to specify the size of the right column, but I am
limiting the left column to 200 pixels in width.

Is this possible?

Thanks for any help.


H1,H2,H3,H4 {text-align: center}

Thanks David Dorward for reminding me that that was what I was using.

Mason C notorious invalidator at http:/masonc.home.netcom.com/1index.html
Jul 20 '05 #14

P: n/a
On Tue, 13 Apr 2004 23:15:10 GMT, BenOne© <no**@m.thanks.mate> wrote:
Hi,

I am trying to create a simple two column layout, with a heading centred in the
right column. I don't want to specify the size of the right column, but I am
limiting the left column to 200 pixels in width.

Is this possible?

Thanks for any help.


H1,H2,H3,H4 {text-align: center}

Thanks David Dorward for reminding me that that was what I was using.

Mason C notorious invalidator at http:/masonc.home.netcom.com/1index.html
Jul 20 '05 #15

P: n/a
MasonC wrote:
On Tue, 13 Apr 2004 23:15:10 GMT, BenOne© <no**@m.thanks.mate> wrote:

Hi,

I am trying to create a simple two column layout, with a heading centred in the
right column. I don't want to specify the size of the right column, but I am
limiting the left column to 200 pixels in width.

Is this possible?

Thanks for any help.

H1,H2,H3,H4 {text-align: center}

Thanks David Dorward for reminding me that that was what I was using.

Mason C notorious invalidator at http:/masonc.home.netcom.com/1index.html


Thanks to all for the replies.

--
Ben Thomas

Apparently less than 10% of accidents are caused by drivers exceeding the speed
limit.
Jul 20 '05 #16

P: n/a
David Dorward wrote:
BenOne© wrote:

I am trying to create a simple two column layout, with a heading centred
in the right column. I don't want to specify the size of the right column,
but I am limiting the left column to 200 pixels in width.

#sidebar {
width: 200px;
position: absolute; top: 0; left: 0;
}

#content {
margin-left: 200px;
}

#content h1 { text-align: center; }

(Most margins and padding have not been accounted for, the above will cause
overlaps, however it does show a technique that should work)


Why set the margin-left of the content to 200, instead of setting left to 200?

--
Ben Thomas

Apparently less than 10% of accidents are caused by drivers exceeding the speed
limit.
Jul 20 '05 #17

P: n/a
MasonC wrote:
On Tue, 13 Apr 2004 23:15:10 GMT, BenOne© <no**@m.thanks.mate> wrote:

Hi,

I am trying to create a simple two column layout, with a heading centred in the
right column. I don't want to specify the size of the right column, but I am
limiting the left column to 200 pixels in width.

Is this possible?

Thanks for any help.

H1,H2,H3,H4 {text-align: center}

Thanks David Dorward for reminding me that that was what I was using.

Mason C notorious invalidator at http:/masonc.home.netcom.com/1index.html


Thanks to all for the replies.

--
Ben Thomas

Apparently less than 10% of accidents are caused by drivers exceeding the speed
limit.
Jul 20 '05 #18

P: n/a
David Dorward wrote:
BenOne© wrote:

I am trying to create a simple two column layout, with a heading centred
in the right column. I don't want to specify the size of the right column,
but I am limiting the left column to 200 pixels in width.

#sidebar {
width: 200px;
position: absolute; top: 0; left: 0;
}

#content {
margin-left: 200px;
}

#content h1 { text-align: center; }

(Most margins and padding have not been accounted for, the above will cause
overlaps, however it does show a technique that should work)


Why set the margin-left of the content to 200, instead of setting left to 200?

--
Ben Thomas

Apparently less than 10% of accidents are caused by drivers exceeding the speed
limit.
Jul 20 '05 #19

P: n/a
BenOne© wrote:
Why set the margin-left of the content to 200, instead of setting left to
200?


Rule 1[1]: Never position anything you don't have to.

As the element isn't positioned, the left property doesn't apply.

Why left instead of margin-left?

[1] of my loosely defined personal ruleset of CSS authoring
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Jul 20 '05 #20

P: n/a
BenOne© wrote:
Why set the margin-left of the content to 200, instead of setting left to
200?


Rule 1[1]: Never position anything you don't have to.

As the element isn't positioned, the left property doesn't apply.

Why left instead of margin-left?

[1] of my loosely defined personal ruleset of CSS authoring
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Jul 20 '05 #21

P: n/a
David Dorward <do*****@yahoo.com> wrote:
Rule 1[1]: Never position anything you don't have to.


But many people think they have to.

--
Spartanicus
Jul 20 '05 #22

P: n/a
/Spartanicus/:
David Dorward <do*****@yahoo.com> wrote:
Rule 1[1]: Never position anything you don't have to.


But many people think they have to.


They just gotta understand they shouldn't - they should realize that
things are being laid out so they can "interact".

--
Stanimir
Jul 20 '05 #23

P: n/a
David Dorward <do*****@yahoo.com> wrote:
Rule 1[1]: Never position anything you don't have to.


But many people think they have to.

--
Spartanicus
Jul 20 '05 #24

P: n/a
/Spartanicus/:
David Dorward <do*****@yahoo.com> wrote:
Rule 1[1]: Never position anything you don't have to.


But many people think they have to.


They just gotta understand they shouldn't - they should realize that
things are being laid out so they can "interact".

--
Stanimir
Jul 20 '05 #25

P: n/a
David Dorward wrote:
BenOne© wrote:

Why set the margin-left of the content to 200, instead of setting left to
200?

Rule 1[1]: Never position anything you don't have to.

As the element isn't positioned, the left property doesn't apply.

Why left instead of margin-left?

[1] of my loosely defined personal ruleset of CSS authoring


How is setting margin-left _not_ positioning?

--
Ben Thomas

Apparently less than 10% of accidents are caused by drivers exceeding the speed
limit.
Jul 20 '05 #26

P: n/a
David Dorward wrote:
BenOne© wrote:

Why set the margin-left of the content to 200, instead of setting left to
200?

Rule 1[1]: Never position anything you don't have to.

As the element isn't positioned, the left property doesn't apply.

Why left instead of margin-left?

[1] of my loosely defined personal ruleset of CSS authoring


How is setting margin-left _not_ positioning?

--
Ben Thomas

Apparently less than 10% of accidents are caused by drivers exceeding the speed
limit.
Jul 20 '05 #27

P: n/a
BenOne© <no**@m.thanks.mate> wrote:
How is setting margin-left _not_ positioning?


Imagine that several boys are lining up alphabetically, perhaps in gym
class or something: Arthur Adams, Brian Brown, Charles Carter, etc.

CSS positioning is like telling a boy exactly where to stand, even if that
seems to move him out of his normal order in line.

Setting margin-left is like telling a boy to hold out his left arm, and
leave that much room between himself and the boy to his left.

Does that help?
--
Darin McGrew, mc****@stanfordalumni.org, http://www.rahul.net/mcgrew/
Web Design Group, da***@htmlhelp.com, http://www.HTMLHelp.com/

"There is no right way to do the wrong thing."
Jul 20 '05 #28

P: n/a
BenOne© <no**@m.thanks.mate> wrote:
How is setting margin-left _not_ positioning?


Imagine that several boys are lining up alphabetically, perhaps in gym
class or something: Arthur Adams, Brian Brown, Charles Carter, etc.

CSS positioning is like telling a boy exactly where to stand, even if that
seems to move him out of his normal order in line.

Setting margin-left is like telling a boy to hold out his left arm, and
leave that much room between himself and the boy to his left.

Does that help?
--
Darin McGrew, mc****@stanfordalumni.org, http://www.rahul.net/mcgrew/
Web Design Group, da***@htmlhelp.com, http://www.HTMLHelp.com/

"There is no right way to do the wrong thing."
Jul 20 '05 #29

P: n/a
BenOne© wrote:
David Dorward wrote:
BenOne wrote:
Why set the margin-left of the content to 200, instead of setting
left to 200?


Rule 1[1]: Never position anything you don't have to.


How is setting margin-left _not_ positioning?


David Dorward was talking about positioning in the css sense, that is,
using "position: absolute" or "fixed", which takes an element out of the
normal document flow. This usually makes things more difficult elsewhere
in your layout. Setting a margin left does not, by itself, take a
document out of the flow. It merely increases the box taken up by the
element.

--
Brian (remove "invalid" from my address to email me)
http://www.tsmchughs.com/
Jul 20 '05 #30

P: n/a
BenOne© wrote:
David Dorward wrote:
BenOne wrote:
Why set the margin-left of the content to 200, instead of setting
left to 200?


Rule 1[1]: Never position anything you don't have to.


How is setting margin-left _not_ positioning?


David Dorward was talking about positioning in the css sense, that is,
using "position: absolute" or "fixed", which takes an element out of the
normal document flow. This usually makes things more difficult elsewhere
in your layout. Setting a margin left does not, by itself, take a
document out of the flow. It merely increases the box taken up by the
element.

--
Brian (remove "invalid" from my address to email me)
http://www.tsmchughs.com/
Jul 20 '05 #31

This discussion thread is closed

Replies have been disabled for this discussion.