Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 10th, 2006, 08:25 AM
takigama@gmail.com
Guest
 
Posts: n/a
Default CSS and tables.

Hi all,

Im relatively new to css, i've used it for very generic stuff, but not
to the extent im using it in my current project. the question i have is
this.

Why doesnt this do what i thought it would:

css
-----
..pos_table {
border: 0px #ffffff solid
}

A.pos_table:link,A.pos_table:active,A.pos_table:vi sited {
font-size: 23px;
}

A.pos_table:hover {
font-size: 23px;
}

TH.pos_table {
font-size: 23px
}
-----

html
------
<div class="pos_table">
<table><tr><th>my header</th></tr><tr><td><a
href="somelink>text</a></table>
</div>

------

i was expecting that the TH.pos_table would make "my header" font size
23... but it doesnt, it reverts to what i've define TH do be, not
TH.pos_table. Instead, i find i have to:

....<th class="pos_table">...</th>

The same case with the href.. i.e. <a class="pos_table"....>

Why? or is this just a case of "your an idiot, you dont define it like
that in the first place anyway". It seems needlessly wastefull to have
to define which class everything inside the div is? What obviously
invalid assumptions have i made about how css works?

  #2  
Old August 10th, 2006, 09:45 AM
Christian Kirsch
Guest
 
Posts: n/a
Default Re: CSS and tables.

takigama@gmail.com schrieb:
Quote:
Hi all,
>
Im relatively new to css, i've used it for very generic stuff, but not
to the extent im using it in my current project. the question i have is
this.
>
Why doesnt this do what i thought it would:
>
css
-----
.pos_table {
border: 0px #ffffff solid
}
>
A.pos_table:link,A.pos_table:active,A.pos_table:vi sited {
font-size: 23px;
}
The regulars in this group seem to consider font-size specifications
in pixels BAD. They prefer em or percent sizes.
Quote:
>
A.pos_table:hover {
font-size: 23px;
}
>
TH.pos_table {
font-size: 23px
}
-----
>
html
------
<div class="pos_table">
<table><tr><th>my header</th></tr><tr><td><a
href="somelink>text</a></table>
</div>
>
------
>
i was expecting that the TH.pos_table would make "my header" font size
23... but it doesnt, it reverts to what i've define TH do be, not
TH.pos_table. Instead, i find i have to:
>
...<th class="pos_table">...</th>
>
The same case with the href.. i.e. <a class="pos_table"....>
>
Why? or is this just a case of "your an idiot, you dont define it like
that in the first place anyway". It seems needlessly wastefull to have
to define which class everything inside the div is? What obviously
invalid assumptions have i made about how css works?
>
TH is a child of an element whose class is 'pos_table' (namely the
DIV). What you specified in your class selectors are elements of class
'pos_table', whose *parent* is either a link (A) or a table header
(TH). You might want to check your CSS documentation, in particular
the different selectors.

In addition, in CSS not all attributes are propagated to descendants.
Notably, border styles never propagate. In addition, certain browsers
seem(ed?) to have problems applying font attributes defined for the
enclosing element to a table.
  #3  
Old August 10th, 2006, 09:45 AM
David Dorward
Guest
 
Posts: n/a
Default Re: CSS and tables.

takigama@gmail.com wrote:
Quote:
TH.pos_table {
font-size: 23px
Avoid pixels for font size.
http://css-discuss.incutio.com/?page=UsingPixels
Quote:
<div class="pos_table">
<table><tr><th>my header</th></tr><tr><td><a
Quote:
i was expecting that the TH.pos_table would make "my header" font size
23... but it doesnt, it reverts to what i've define TH do be, not
TH.pos_table.
The th element is not a member of the pos_table class, it is a
descendent of such a member.

You want to use a descendent selector.
http://www.w3.org/TR/CSS2/selector.h...dant-selectors

  #4  
Old August 10th, 2006, 11:45 AM
Andy Dingley
Guest
 
Posts: n/a
Default Re: CSS and tables.


takigama@gmail.com wrote:
Quote:
Why doesnt this do what i thought it would:
Quote:
TH.pos_table {
Quote:
<div class="pos_table" >
<table><tr><th>my header</th></tr><tr><td><a
You applied the class (quite rightly) to a container around the table.
You might possibly have been able to skip that <divand just use
<table class="pos_table" >

For a CSS selector try this

.pos_table th { ... }

Note that .pos_table th, th.pos_table and th .pos_table are all quite
different CSS selectors.


PS - Don't use font sizing in pixels.

Don't apply font sizing to inline elements (you can do this, but it's
really unusual to need to modify this - just let the settings inherit).

Don't set font-size, font-weight or a few other settings from an :hover
{} rule. It makes for links that jump around when you hover over them.

  #5  
Old August 10th, 2006, 07:25 PM
Nije Nego
Guest
 
Posts: n/a
Default Re: CSS and tables.

On 10 Aug 2006 00:32:01 -0700, takigama@gmail.com wrote:

The question:
Quote:
Why doesnt this do what i thought it would:
is being repeated endesly eversince.

--
buy, bought, bye
 

Bookmarks

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles