About the ID attribute in HTML

Hello Seniors,

I am new to HTML and working on this exercise:

I just wanted to know that:
Is any naming guidelines for the ID or the Name of input or label element in HTML?

Like in this example I am adding a new input having name “Green Pepper”. I am using this name as an ID and name of the input element.

like this:
Green Pepper

I mean can I use space between words in id or label or the value?

Please guide. _/_

Hi there,

So, elements can only have a single ID value. If you wanted to give an ID value such as “green pepper” you would need to do something like greenPepper, green-pepper, or green_pepper. On the other hand, spaces can be included when giving multiple classes. Consider the space a comma, as the space separates the previous class from the next.

Such as:

class="class1 class2 class3"

Thank you so much for the clarification!! :pray:

1 Like