Can I have ID and Class in the Same Element?

Face it… You’re “human” too. Hey, it’ll be “our” little secret… Wink wink… Nudge nudge

You have more than ten different “boxes” there’s something wrong structurally or the design is absurdly inconsistent… or it’s knee deep in “too many nested DIV”. IF it were to reach that point for a legitimate reason (hard to think of one) that’s when I’d be considering adding the class…

Maybe, maybe not.

In an ideal world, everything on every website out there would be distilled down into a page of CSS styles. Then again, life and the Internet would be pretty boring if the world was that one-dimensional…

The idea of my “boxes” is to provide a consistent “container” to disparate information, but that doesn’t mean that content will fit into one of 10 “flavors”…

Won’t know until I get there. I strive for consistency, but I can think of lots of different ways to display my “widgets”…

So I’ll shoot for that for now.

I’m not sure what polymorphism has to do with it; though I’ve begun to suspect that said word is being used much akin to ‘web 2.0’ so far as marketspeak goes. It would be a very proactive paradigm. (6 minute mark)

I’ve re-read that thread three times now, and I’m having trouble deciphering the question or point of it… as opposed to this thread… Same question isn’t it?

“polymorphism in the context of object-oriented programming, is the ability to create a variable, a function, or an object that has more than one form. The word derives from the Greek “πολυμορφισμός” meaning “having multiple forms”. In principle, polymorphism can however arise in other computing contexts and it shares important similarities to the concept of degeneracy in biology.”

http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming

I mentioned the term “polymorphism” loosely because if I create a base “box” and then I customize it using Classes then that base “box” becomes “polymorphic” in essence…

Debbie

Then don’t just try it in one browser, try it with the W3 validator. If that gives you a big green tick then all is well with the world and your code.

I found an article in 2004 that says, “Yes, you can do it.”

Code that was valid in 2004 hasn’t become invalid in the meantime.

But would you want to and what are the consequences?! :-/

As others have said, it works absolutely fine (as long as you don’t try chaining and you get your specificities right), and the consequence is that it gives you a much simpler and more straightforward code both in the HTML and the CSS.

Remember that the ID could equally well be used as an internal link point or Javascript reference – not being able to put a class (for styling) on the element would become unworkably restrictive.