How to add html tag in a form element? How to add html tag in a form element drupal 8?

$form['buttons']['submit'] = [
  '#type' =&gt; 'submit',
  '#value' =&gt; T('Send'),
  '#prefix' =&gt; '&lt;div class="modal-footer"&gt;',
  '#suffix' =&gt; '&lt;button type="button" class="btn btn-sm btn-default" data-dismiss="modal"&gt;' . $this-&gt;t('Close') . '&lt;/button&gt;&lt;/div&gt;',      
  '#attributes' =&gt; [
    'class' =&gt; ['btn-success'],
  ]
];


I try to add allowed_tags:

$form['buttons']['submit'] = [
  '#type' =&gt; 'submit',
  '#value' =&gt; T('Send'),
  '#prefix' =&gt; '&lt;div class="modal-footer"&gt;',
  '#suffix' =&gt; '&lt;button type="button" class="btn btn-sm btn-default" data-dismiss="modal"&gt;' . $this-&gt;t('Close') . '&lt;/button&gt;&lt;/div&gt;',
  '#allowed_tags' =&gt; ['button'],
  '#attributes' =&gt; [
    'class' =&gt; ['btn-success'],
  ]
];


OR

$form['buttons']['#allowed_tags'] = ['button'];
$form['#allowed_tags'] = ['button'];


Not working...
Help me please!
I can't tell which element is giving you trouble.

For the div, instead of prefix/suffix you can create a container element:

$form['submit_container'] = array(
  '#type' =&gt; 'container',
  '#attributes' =&gt; array(
    'class' =&gt; ['modal-footer'],
  )
);


And then you can put a submit input inside of that:

$form['submit_container']['submit'] = array(
  '#type' =&gt; 'submit',
  '#value' =&gt; $this-&gt;t('Submit'),
  '#attributes' =&gt; array(
    'class' =&gt; ['btn', 'btn-sm', 'btn-default'],
    'data-dismiss' =&gt; 'modal',
  )
);


If you need a button type='button' just to fire Javascript and not submit the form, that is somewhat problematic, it seems. One method is to override the button template.

Type inline_template may be the best bet:

$form['submit_container']['button'] = array(
  '#type' =&gt; 'inline_template',
  '#template' =&gt; '&lt;button type="button" class="btn btn-sm btn-default" data-dismiss="modal" onclick="closeButton()"&gt;Close&lt;/button&gt;',
);


Change a normal submit &#39;input&#39; type to &#39;button&#39; type with button tag