Define multiple "ids" in an HTML tag [duplicate]

1

HTML allows you to define several class in a single loop. Curiously, I tried to do the same, trying to define several id in a tag :

<div id="id1 id2 id3">Tester plusieurs id</div>

It did not work, ie HTML ignored all these classes.

Am I doing wrong or is it simply not allowed by HTML?

OBS: Simply a curiosity

    
asked by anonymous 25.04.2017 / 14:28

3 answers

4

Multiple ids per element is not allowed:

  

The value of this attribute should not contain any gaps (spaces, tabs   etc.). Browsers treat inappropriate IDs that contain gaps like   if the gaps were part of the ID. In contrast to the class attribute,   which allows multiple values separated by space, the elements can   have only a single ID.

Documentation

    
25.04.2017 / 14:30
2

When you use an id it must be unique to your given element (TAG). The class can be repeated and can contain as many as you need in the same element.

Avoid repeating ids on the same page, if you need to identify multiple elements with the same name, use class.

    
25.04.2017 / 14:32
1

I do not think you can do that, my friend. You can use more than one class (already created) in a class of a tag.

    
25.04.2017 / 14:30