Search code examples
cssstylesheetcsslint

"Don't use IDs in selectors (CSS)" then, what to use instead of IDs?


One of CSS lint rules is: "It's better to not use IDs in selectors". So, what should we use instead of IDs to point to a unique element? For example, say I have dozens of elements that have a class named my-class, and I want only one of them to have a special CSS property. What can I do?


Solution

  • give them another class for example:

    <div class="myClass special"></div>
    
    .myClass.special{
      color: red;
    }