Where is the best place to declare the active class of an element?

  • 0
    Please tell me where it is better to declare a default active class for an element.
    In the HTML itself
    <li class="fitler_item active_filter" data-filter="all">All</li>

    or in js
    if (indx == 0) {
        items.classList.add('active_filter')
      }

    JavaScript Anonymous, Jun 13, 2020

  • 2 Answers
  • 0
    if this element is always active by default, then it is better in html
    Anonymous

  • 0
    Best in css I think.
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!