how to add other component (html tag, js, and css) in form module Suppose I have the following code.

class customCreateForm extends FormBase {

/* code code code... */

  public function getFormId() { /* code */ }
  public function buildForm(array $form, FormStateInterface $form_state) {

    $form['label'] = array(
      '#type' =&gt; 'textfield',
      '#title' =&gt; t('title'),
      '#description' =&gt; $this-&gt;t('Your title'),
      '#default_value' =&gt; "",
      '#size' =&gt; 10,
      '#maxlength' =&gt; 8,
      '#required' =&gt; TRUE,
    );
    /* code code code... */
    return form;
  }
  /* code code code... */
}


I can understand how to add a form element, but how can I add HTML markup or JavaScript?

For example, I want to add the following in my custom form.

&lt;link type="text/css" rel="stylesheet" href="bla..."&gt;

&lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt;&lt;/script&gt;

&lt;div id="something" class="something"&gt;
        &lt;img src="bla" /&gt; 
    &lt;/div&gt;
&lt;table id="something" class="something"&gt;&lt;tr&gt;&lt;td&gt;aaa&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;script&gt;
/* code code code */
&lt;/script&gt;

&lt;script src="https://maps.googleapis.com/maps/api/js?key=aaaa&amp;libraries=places&amp;callback=initAutocomplete" async defer&gt;&lt;/script&gt;
you should add a library like this :

$form['#attached']['library'][] = 'my_module/mylibrary';


Create mylibrary.libraries.yml file with the content :

mylibrary:
  version: 1.x
  css:
    theme:
      css/my-css.css: {}
  js:
    js/my-js.js: {}


more documentation: https://www.drupal.org/developing/api/8/assets