How to set page-specific CSS classes on the page callback build array? I have a page callback like this:

function example_page() {
  $build = array();

  $build['#attributes'] = array('class' =&gt; array('example-class'));

  $build[] = array(
    '#markup' =&gt; '&lt;p&gt;My text here&lt;/p&gt;',
  );

  return $build;
 }


As you can see, I have attempted to add classes to the div that wraps the output of the render array in the same fashion as the form API works. I have also tried setting $build['classes'] or $build['classes_array'], but all of these tree syntaxes are ignored, and the content is simply wrapped in &lt;div class="content"&gt;, which is not very helpful.
#attributes is the correct property, but the problem is that $build itself is not actually an render element (unless make it one), it's just a collection of render elements.

To make it an actual render element, you have to set the #type property to for example 'container'. That is nothing more than a div with attributes that contains other elements. See When should the &quot;container&quot; form element be used? and theme_container().

You can however not affect the mentioned content div, that is outside of your control. Adding a container will add a new div inside that one.