HighDots Forums  

Re: Inheritance within tag hierarchies

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Re: Inheritance within tag hierarchies in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Inheritance within tag hierarchies - 12-09-2007 , 03:41 AM






Scripsit Puzzled:

Quote:
I'm obviously reading the docs wrong, or doing something wrong,
Well, yes. It's almost evident from the Subject line, since more than
99% of people's questions formulated in terms of inheritance are based
on completely wrong assumptions (and mostly have nothing to do with
inheritance).

Quote:
so I hope someone can put me right.
OK, but it won't be easy.

Quote:
What I want is to be able to define a style
Technically, style sheets have no style. That is, "a style" is not a CSS
term. CSS has properties, values, declaration, rules, and styles sheets
(to proceed bottom up in the hierarchy of concepts). Informally, we
might call a collection of declarations "a style", and this is probably
what you mean.

Quote:
and apply it to, say,
a <td>, define another style and have it apply to embedded <a>s
within that <td> regardless of any intermediate unstyled nesting.
OK, that should be easy.

Quote:
E.g., if the <a> is within an unstyled <p> (i.e. nothing being
inherited from the <p/>), it should still use the style defined
for <a> inside <td>.
Here's the first mistake: "nothing being inherited from the <p/>". An
element can surely inherit from an "unstyled" parent, since such a
parent (as any element) has all the properties there are in CSS.

Quote:
I shouldn't have to define the case of the
a> within a <p> within the <td>.
You don't. When you assign a value to a property of an element, then
that element does not inherit a value for that property, no matter where
the element is nested.

Quote:
As I read the docs, this should work:

*[class="tdclassname"] A {definition}
Here "definition" should be replaced by "declaration(s)".

It should work, but the following is much safer, since it works on IE
prior to IE 7, too:

..tdclassname A {declaration(s)}

Quote:
so both <a> tags here:
td class="tdclassname"
a ...
p/
a ...
/td

...should have the same style.
Uh... tags have no style. Elements have style. And you probably mean <a
....>...</a>, since an <a> element always needs an end tag. Moreover,
<p/> is all wrong: such notation is strongly discouraged (though
formally permitted both in classic HTML and in XHTML, with completely
different meanings), and in XHTML it is formally equivalent to <p></p>,
i.e. an empty paragraph, which should (by HTML specs) not be used and
should (by HTML specs) be ignored by browsers, though in practice they
tend tp present it as some amount of empty space.

There's little hope in successful use of CSS before you have the markup
at least roughly right.

Whether the two <a> elements have "the same style", which probably means
same values for properties, really depends on other style sheets,
possibly even browser default style sheets. But what you set in

..tdclassname A {declaration(s)}

applies equally well to the <a> element that resides as nested inside a
<p> element.

However, for example, if you have

body { font-family: Arial; }
p { font-family: Calibri; }

(just to take a definite, though foolish, example) and no other
font-family settings anywhere, then the <a> element nested inside a <p>
element will inherit font-family from its parent, i.e. appear in
Calibri, unlike the other <a> element, which is in Arial. You can easily
prevent this by explicitly setting, for example,

a { font-family: Arial; }

which makes all <a> elements appear in Arial. But there is no way to
prevent an element from inheriting a property from its parent except by
setting a value for that property for that element.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/



Reply With Quote
Reply




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.