44

The time I had to explain to my CS professor that HTML elements can in fact have multiple classes.

Comments
  • 1
    He's probably not a web dev though
  • 0
    Well, can they? I don't have the time to test, but if you gave an element two classes and in JS asked for its className, what would it return?

    Im assuming the most recent class applied. Either that or the two classes seperated by some sort of delimiter.
  • 0
    @AlgoRythm Having multiple is kinda the whole point of classes.
    In JS, className is the string value of the class attribute, which is all classes, separated by spaces.
  • 0
    @franga2000 Nah, ya got it backwards. The point of classes is multiple different elememts can have the same class, as opposed to id. It is also true that elements can have multiple classes, but this isn't the main idea.
  • 1
    @AlgoRythm Right, fair point. It's still something that is mentioned in the first paragraph on W3Schools. I really hope he won't be teaching us HTML next year
  • 0
    @franga2000 God, I hope not. Best of luck
Add Comment