Mitchell Waite wrote:
This looks better on a big screen but do I have this right?

http://www.whatbird.com/wwwroot/images/addClass.gif

The description of the Javascript is pretty good. Dan had some good suggestions of how it might be done better, but your exposition of what's happening inside the script tag is great.

However, your description of the CSS is problematic.

The following has structure, and that structure can be analyzed, but for many purposes it needs to be treated as a whole:

    tr.foo td

This is a selector, and your notes that point to the "foo" to say that "class 'foo' styles the TR" is not really correct. The whole line points to some elements that need to be styled, namely those TD elements that are inside TR elements with the class "foo". Nothing in this rule will style the TR as a whole. A separate rule, say

    tr.foo {
        background-image: /images/boat.png
        font-weight: bold;
    }

could be used to style the actual TR elements.

There's one other problem. The note that says "and it makes each cell (TD) = yellow" is correct, but it's pointing to the wrong place. You are pointing to the "td" in the selector; you should be pointing to the declaration "background-color: yellow;". The selector chooses which elements you want to style. It's the declarations that hold the actual styles to use.

Finally, in an exposition like this, it would probably help to indent the declarations inside their block.

The above sounds fairly critical, and I don't want to leave the impression that I think it's awful. I think this is a great expository technique. But if it's aimed at beginners, there should be no mistakes!

Cheers,

  -- Scott

Reply via email to