First let me say Hello!
I'm new here and this is my first post.
Of course I'm here because I'm an old dog trying to learn new tricks, and instead I feel like I'm trying to learn Chinese ha ha. I'm trying to put my content into one of those free web templates and it's not working out for me, so I'm about to pull my hair out.
As I was searching to see if anyone else had posted about my particular problem, I ran across a tutorial here about Classes and ID's. Unfortunately, this tutorial is the exact same as the million other tutorials on the internet. They all say "You must use an ID only ONCE per page", and then just leave you to accept this on faith alone. Why once per page?
Of course this stupid template is made with nothing BUT ID's, so to get the look I want I've just been using them over and over again on the same page. Works fine for me. At least I've seen no ill effect.
So in laymans terms, why is an ID to be used only once? Why can't it be used in multiple places?
On another note, is CSS and XHTML really worth all the bother? It seems they took a perfectly good working code (HTML 4) and turned it into something requiring an MIT graduate in the top 10% of his class. I'm reaching a point of frustration where I'm ready to chuck this hoity-toity XHTML and go back to my old layout.
Id's are used when you want to target a specific element, not only with CSS but also DOM.
As for learning XHTML, that's a choice you will have to make. You could stick with HTML just try to keep it valid. There are topics all over the forms and web on why you should validate your markup.
The question of HTML Vs.
The question of HTML Vs. XHTML gets covered quite regularly here in some depth please hunt around and have a read of those threads, but as for XHTML being complex it is not at all it only requires a few strict rules regarding code syntax.
As for disregarding instructions regarding the use of an ID only once that is simply foolish yes ask the question 'why' but accept that as it is the repeated instruction everywhere that it must be adhered to; as for your pages seemingly working using repeated ID names they wont be! I would check in a modern browser and also validate your work
Use classes if you wish to repeat rulesets for multiple elements, classes belong to CSS ID's on the other hand belong to markup in general and have other uses apart from attaching styling to an element and have to be unique to prevent conflicts where a script needs to know which element it is dealing with.
Edit/ beaten to it!
Thanks fellows, And please
And please accept my apologies for being a bit terse tonight. I've been dealing with this for hours now and now that I'm getting on in years (and expecting my first grand-child) I find that my patience level (and subsequent frustration tolerance) has decreased quite significantly :blushing:
No apologies required,
No apologies required, hadn't noticed any particular terseness, but do understand decreasing tolerance with advancing years
Think of it like Drivers Licenses
You and only you can have your ID. Anyone else caught with your ID is in trouble.
You and everyone you know can have a 'Class C' license.
If you and 100 other people had the same ID, how chaotic would voting be? or banking? or college registration? or or or... same exact idea.