NAME, ID, and CLASS in Dynamic HTML and JavaScript Image Arrays
by Taylor5 Feb 1998
Page 1
Look through the source of many dynamic HTML pages, or pages that use the JavaScript array of images and links, and you'll notice that many of the tags have been given NAMEs, IDs, and CLASSes. While you might have correctly surmised that these are used as identifiers for other elements, stylesheets and server-side scripts, the differences between NAME, ID, and CLASS might seem a little fuzzy. When do you use ID instead of NAME? Should you just use CLASS for everything?
To answer these questions, I have a parable about everyone's favorite Active-Movie-Control-lovin' monkey, Shvatz.
I've known Shvatz for a long time. We went to school together and now work together. When people first hear his NAME, they often pause because it's weird. "Shvatz?" they ask, "How do you pronounce that?" (I always pull out my phoneme chart and give them a quick linguistics lesson.)
Of course, he's not Shvatz to everyone - especially teachers. They used to call him "Craig Adam Schwartz," because that was the name on his student ID. It is his official name after all. That's how he was named on the WANTED posters when the authorities were searching for him for behavior like streaking the quad or illegally cloning humans; the posters had his official ID and a description of him. His parents were embarrassed, but we thought he was cool.