title: Set the `class` attribute of a dynamically-created element in JavaScript
body: <p>I have a custom element, which is created like:</p>
  
  <pre><code>connectedCallback()
  {
    var on_off_switch = document.createElement('Div');
    on_off_switch.class = 'switch demo3';
  
    this.appendChild(on_off_switch);
  
   }
  </code></pre>
  
  <p>But I noticed when viewing the source that the <code>on_off_switch</code>'s class is not set to <code>switch demo3</code>.</p>
  
  <p>All other assignments work, like <code>on_off_switch.style['background-color'] = 'red'</code>, etc.</p>
  
  <p>Is it possible to set the CSS <code>class</code> of a element appended inside a custom element?</p>