Add a custom attribute to the main div of a node only on teaser view mode
We can use preprocess function to change OR add an attribute to our node main div.

function MYMODULE_preprocess_node(&amp;$variables){

  // Array of aatributes which we want to pass to the node div.
  $attr_array = ['tarbot' =&gt; 'value']; 

  // Condition for teaser format.
  if ($variables['teaser'] == TRUE) { 

    $variables['attributes_array'] = $attr_array;   
  }
}


by using this function we will get our node div in this form

&lt;div class="node" tarbot="value"&gt; &lt;/div&gt;