Why I can't use the same code from Drupal 7 in Drupal 8 to generate a button with FAPI? Following the question Generating &lt;button type=&quot;submit&quot;&gt; with the form API for Drupal 7 I tried to implement the same thing in Drupal 8.

I need the following output: 

&lt;button type="submit" class="clearfix"&gt;&lt;span&gt;Login&lt;/span&gt;&lt;/button&gt;


So I tried to use this code:

$form['submit'] = array(
  '#prefix' =&gt; "&lt;button type ='submit'&gt;",
  '#suffix' =&gt; "&lt;/button&gt;",
  '#type' =&gt; 'markup',
  '#markup' =&gt; "&lt;span&gt;" . t('Login') . "&lt;/span&gt;",
);


But I obtain this:

&lt;span&gt;Login&lt;/span&gt;


But if I use this code:

$form['submit'] = array(
  '#prefix' =&gt; "&lt;b&gt;",
  '#suffix' =&gt; "&lt;/b&gt;",
  '#type' =&gt; 'markup',
  '#markup' =&gt; "&lt;span&gt;" . t('Login') . "&lt;/span&gt;",
);


I obtain this:

&lt;b&gt;&lt;span&gt;Login&lt;/span&gt;&lt;/b&gt;


So the &lt;button&gt; tag is eliminated but the &lt;b&gt; tag not. Very strange for me, the Button is not rendered.

Thanks to @Kevin I used the leymannx answer an with this code I solve the problem:

$form['submit'] = [
  '#type' =&gt; 'inline_template',
  '#template' =&gt; '&lt;button type="submit" class="glyphicon glyphicon-search"&gt;&lt;/button&gt;',
];


But, why I can't use the same code in Drupal 7 and Drupal 8 to generate a button with FAPI?
The reason why it is not working in Drupal 8 as in Drupal 7 is, that prefix and suffix are passed to xssFilterAdminIfUnsafe() function in doRender() function. Thus preventing all tags except the tags specified in $adminTags.

Excerpt from doRender:

  // We store the resulting output in $elements['#markup'], to be consistent
  // with how render cached output gets stored. This ensures that placeholder
  // replacement logic gets the same data to work with, no matter if #cache is
  // disabled, #cache is enabled, there is a cache hit or miss.
  $prefix = isset($elements['#prefix']) ? $this-&gt;xssFilterAdminIfUnsafe($elements['#prefix']) : '';
  $suffix = isset($elements['#suffix']) ? $this-&gt;xssFilterAdminIfUnsafe($elements['#suffix']) : '';

  $elements['#markup'] = Markup::create($prefix . $elements['#children'] . $suffix);


You can use '#allowed_tags' property to enable specific tags. So this should work:

  $form['submit'] = array(
  '#type' =&gt; 'markup',
  '#markup' =&gt; "&lt;button type ='submit'&gt;&lt;span&gt;" . t('Login') . "&lt;/span&gt;&lt;/button&gt;",
  '#allowed_tags' =&gt; ['button', 'span'],  
  );


But '#allowed_tags' property will not work for '#prefix' and '#suffix'.