• Post category:HTML

HTML Multiple IDs | Explained

HTML Multiple IDs

We can add multiple ids in one HTML element. IDs must be unique, so you should only use a particular ID once on an element. Instead of ID attributes, we can create multiple classes. If we create two IDs for one element, see what happens in the example code below:


<h1 id="id1 id2">WELCOME TO WONDERDEVELOP</h1>


background-color: pink;
color: red;


html multiple ids

  1. Here, we have created <h1> tag with two id names called id1, and id2.
  2. Then we tried to apply styles for <h1> using both ID names. So, we set “background-color” to “pink” for the id1 name and “color” to “red” for the id2 name
  3. See the output, the <h1> tag does not apply the styles of both IDs, because we should not give more than one identity name.

Leave a Reply