Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Centering a table

Reply
Thread Tools

Centering a table

 
 
David Dorward
Guest
Posts: n/a
 
      04-23-2004
Joshua Beall wrote:

> I thought styles, external or inline, were inherited by child elements.
> You are saying this is not the case? Only styles defined in classes are
> inherited by child elements?


Child elements inherit the values of properties from their parent element
where the child has "property: inherit". The default values for some
properties is 'inherit' on some elements (but not all properties with a
default value of 'inherit' will have that default value for all elements).

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
 
Reply With Quote
 
 
 
 
Steve Pugh
Guest
Posts: n/a
 
      04-23-2004
"Joshua Beall" <(E-Mail Removed)> wrote:
>"Steve Pugh" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed).. .
>>
>> How can you do what I did above with inline styles?

>
>That is what I was asking. If I knew I would not have asked.


It can't be done.

>> That was your problem. You wanted to apply the style to the div that
>> woudl affect the table inside the div. With external styles it's
>> trivial, as demonstrated above. With inline styles it's impossible as
>> you need to put the style attribute on the table not the div.

>
>I thought styles, external or inline, were inherited by child elements. You
>are saying this is not the case? Only styles defined in classes are
>inherited by child elements?


Some properties are inherited, some aren't. Check the specs as to
which. Where they are specified makes no difference.

You specified text-align: center; which is inherited and so all the
text inside your table should be centered inside its cells. You also
specified margin: 0 auto; but margins are not inherited.

You wanted to set margin: 0 auto; on the table. To do this via inline
styles you needed to set <table style="margin: 0 auto;"> which you
don't want to do. Hence you can not use inline styles.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <(E-Mail Removed)> <http://steve.pugh.net/>
 
Reply With Quote
 
 
 
 
Joshua Beall
Guest
Posts: n/a
 
      04-23-2004
"David Dorward" <(E-Mail Removed)> wrote in message
news:c6bsj3$ljn$1$(E-Mail Removed)...
> Joshua Beall wrote:
>
> > I thought styles, external or inline, were inherited by child elements.
> > You are saying this is not the case? Only styles defined in classes are
> > inherited by child elements?

>
> Child elements inherit the values of properties from their parent element
> where the child has "property: inherit". The default values for some
> properties is 'inherit' on some elements (but not all properties with a
> default value of 'inherit' will have that default value for all elements).


But where does inline vs external style declarations fit in?


 
Reply With Quote
 
spaghetti
Guest
Posts: n/a
 
      04-24-2004
On Fri, 23 Apr 2004 14:55:39 GMT, Joshua Beall
<(E-Mail Removed)> wrote:

> No go. Making the outer <div> "<div align='center'>" does the trick.
> But
> is there a way to do it with CSS? the "margin: 0px auto;" centering
> method
> is what I am used to, but it's not working here.


Everyone seems to have gotten lost in a CSS/tables rant, but anyway...

In IE margin: 0 auto for centering doesn't work, but text-align: center
centers block level elements. So if you want to center something in IE the
best way is to use text-align: center on a parent box along with margin: 0
auto (for non-IE browsers), and just text-align: left on the child block
(or table) to make sure the text is not centered in that.

Steve Pugh mentioned adding "whatever hacks you need for IE 6." Well, you
already had them in there. You should not want to use inline styles
though.

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
 
Reply With Quote
 
spaghetti
Guest
Posts: n/a
 
      04-24-2004
On Fri, 23 Apr 2004 20:10:08 GMT, Joshua Beall
<(E-Mail Removed)> wrote:

> But where does inline vs external style declarations fit in?


*cough* they're *cough cough* crazy *cough*

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
 
Reply With Quote
 
Steve Pugh
Guest
Posts: n/a
 
      04-24-2004
spaghetti <(E-Mail Removed)> wrote:
>On Fri, 23 Apr 2004 14:55:39 GMT, Joshua Beall
><(E-Mail Removed)> wrote:
>
>> No go. Making the outer <div> "<div align='center'>" does the trick.
>> But
>> is there a way to do it with CSS? the "margin: 0px auto;" centering
>> method
>> is what I am used to, but it's not working here.

>
>Everyone seems to have gotten lost in a CSS/tables rant, but anyway...


Mainly beacuse the original question was answered in the first reply,
but then the resident moron joined in.

>In IE margin: 0 auto for centering doesn't work,


It does in IE6, unless you trigger quirks mode.

>Steve Pugh mentioned adding "whatever hacks you need for IE 6."


No I said "IE <6". IE6 gets things right unless you deliberately tell
it act like it's stupid older relatives.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <(E-Mail Removed)> <http://steve.pugh.net/>
 
Reply With Quote
 
spaghetti
Guest
Posts: n/a
 
      04-24-2004
On Sat, 24 Apr 2004 09:59:56 +0100, Steve Pugh <(E-Mail Removed)> wrote:

> Mainly beacuse the original question was answered in the first reply,


Oopsie, I didn't see the original answer. My news-server is a bit behind.


--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
centering things within a table laredotornado@zipmail.com HTML 3 11-16-2007 09:04 PM
Centering Text in Table in IE6 Guy Noir HTML 0 11-11-2006 04:14 PM
Vertically centering a form in a table JonABurgess@gmail.com HTML 1 07-22-2006 10:00 PM
Centering ValidationSummary in a cell of a table NWx ASP .Net 1 02-11-2004 06:22 PM
Horizontal and vertical centering of a table Tomas HTML 3 10-31-2003 10:14 AM



Advertisments