[UPHPU] Validation
Jon Jensen
jon at jenseng.com
Tue Jun 6 18:50:12 MDT 2006
> Perhaps I shouldn't have said you need ID and CLASS attributes on
> *everything* because you are right, you certainly don't. And
> I also agree with all the comments about re-writing the tags,
> there is definitly no point. But your good example is not
> really a good example.
Well, it depends on what kind of example you're talking about... We were
talking about HTML/CSS, not JavaScript/DOM manipulation. So by the original
definition, mine is still the better example ;-)
But you are right when it comes to the DOM... getElementById is the best way
to access an element.
I think we are more or less in agreement here, though we are looking at it
from opposite ends of the spectrum. My approach is to keep the (X)HTML and
CSS as lean as possible -- don't add id's or classes unless it's the most
efficient way to get the job done:
1. If it's a logical section of the document (header, content, sidebar),
give it an id
2. If it's something you need to access directly via the DOM, give it an id
3. If it is styled differently from other elements of the same type and
there's not a simple selector that can target it using the class/id of a
parent element (e.g. #header h1), give it a class or id.
Otherwise, you're generally wasting your own time typing it, decreasing
readability of your CSS, and increasing bandwidth requirements. Of course,
it's easier said than done, but I find that the more I go in that direction,
the simpler the code ends up and the easier it is to maintain six months
after the fact.
Jon
More information about the UPHPU
mailing list