[thelist] javascript default event handlers, default events. [TIP]

Matt Warden mwarden at gmail.com
Wed Aug 31 09:36:00 CDT 2005


On 8/31/05, Kowalkowski, Lee (ASPIRE) <lee.kowalkowski at hmrcaspire.com> wrote:
> Erm, no... If you use a stylesheet, you still need references to it in your
> markup, we use id="foo" and class="bar" don't we?  Or do we only ever use
> the default HTML element selectors? (good luck, I would encourage that
> actually if it had better support).

id and class have nothing to do with style.

> Taking out all behaviour references from our markup doesn't achieve this.
> Yes we have nice & clean markup, but our code is a lot dirtier.

If that's your opinion, then don't do it. But, make sure you
understand things, first.

> > You're basically saying the
> > JavaScript equivalent of:
> >
> > <foo style="color: red;"> ... </foo>
> >
> > is better than:
> >
> > <foo style="color: red; font-weight: bold; text-align: center:
> > vertical-align: top; float: left;"> ... </foo>
> 
> No, I'm not that silly. 

I'm not calling you silly, but the above is exactly what you're saying.

> I'm saying onsubmit="return validate(this)" is like
> class="foobar";

No. Class has nothing to do with style.

> So I'm saying that
> class="..." is better than style="...", everyone should know that.

No. *Applying style* by class or by tag name or by id is better than
using inline style. But you misunderstand when you say that class has
anything to do with style. It is a way of grouping elements. Where
style comes in is that it's also a way of selecting a group of
elements (but there are many other ways). e.g.:

.paragraph {
    // apply style
}

But, you can also do this:

p {
   // apply style
}

but that certainly doesn't make the paragraph tag a style element.



-- 
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.


More information about the thelist mailing list