How do I put a  around a form? I have created a form that I will embed in my page with a custom module. How can I wrap this form with a div that has a specific class?

I need to add it to the build which is made with the following code.

$build = array(
          'form' =&gt; $form,
          '#type' =&gt; 'markup',
          '#markup' =&gt; $html,
          '#attached' =&gt; array(

             'library' =&gt; array('pup_viewfiles/sortfiles_libraries'),
            ),
        );
There are many different ways to add markup to a form in Drupal 8.  In your build array, you could add a wrapper element, and then nest the form within:

$build['wrapper'] = [
  '#type' =&gt; 'container',
  '#attributes' =&gt; ['id' =&gt; 'my-form-wrapper', 'class' =&gt; ['my-form-wrapper']],
];

$build['wrapper']['form'] = \Drupal::formBuilder()-&gt;getForm('Drupal\mymodule\Form\MyForm');


Alternately you could add a '#prefix' and a '#suffix' to your form.

$form['#prefix'] = '&lt;div class="my-form-wrapper"&gt;';
$form['#suffix'] = '&lt;/div&gt;';


Or you could use a template for your form and add it to your theme, using the suggestion form--form-id.html.twig and add custom markup there.  (Be sure to replace underscores with hyphens in the template name.)

&lt;div id="my-form-wrapper"&gt;
  &lt;form{{ attributes }}&gt;
    {{ children }}
  &lt;/form&gt;
&lt;/dv&gt;