How to use stye attribute in custom block markup?
This is a working example of adding the style attribute to the render array of a block via the build() method.

&lt;?php
/**
 * @file
 * Contains Drupal\foo\Plugin\Block\FooBlock
 */


namespace Drupal\foo\Plugin\Block;
use Drupal\Core\Block\BlockBase;


/**
 * @block(
 *   id = "foo",
 *   admin_label = @Translation("Foo block")
 * )
 */
class FooBlock extends BlockBase {

  /**
   * Builds and returns the renderable array for this block plugin.
   *
   * If a block should not be rendered because it has no content, then this
   * method must also ensure to return no content: it must then only return an
   * empty array, or an empty array with #cache set (with cacheability metadata
   * indicating the circumstances for it being empty).
   *
   * @return array
   *   A renderable array representing the content of the block.
   *
   * @see \Drupal\block\BlockViewBuilder
   */
  public function build() {
    return [
      'inside' =&gt; [
        '#type' =&gt; 'html_tag',
        '#tag' =&gt; 'div',
        '#value' =&gt; 'Hello world',
        '#attributes' =&gt; [
          'class' =&gt; ['some-class'],
          'style' =&gt; ['color:red']
        ]
      ]
    ];
  }
}