The fieldset isn't shown as collapsed I am writing a module that executes some queries, and returns the result in to a collapsed fieldset which is not shown as collapsed; I view its content. The collapse.js files are loaded. 

This is the code I am using.

$body = $body . '&lt;fieldset class="collapsible collapsed"&gt;' . 
  '&lt;legend class="gestioneinterna"&gt;Viste aggiuntive&lt;/legend&gt;' . 
  '&lt;description class="description"&gt;fieldset extra.&lt;/description&gt;' .
  '&lt;div&gt;&lt;p class="home_body "&gt;&lt;a href="?q=vista_progetti_categoria/1"&gt;&lt;strong&gt;Vista progetti&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;';
print $body;
You're missing a closing &lt;/fieldset&gt; tag which probably won't be helping things, but I wouldn't advise doing it the way you currently are anyway.

A better way would be to make use of the theme_fieldset() function like so:

// Make sure the collapsible library is loaded
drupal_add_library('system', 'drupal.collapse');

// Build up the fieldset
$fieldset = array(
  '#theme' =&gt; 'fieldset',
  '#title' =&gt; 'Viste aggiuntive',
  '#attributes' =&gt; array('class' =&gt; array('collapsible', 'collapsed')),
  '#description' =&gt; 'fieldset extra.',
  '#children' =&gt; '&lt;div&gt;&lt;p class="home_body "&gt;&lt;a href="?q=vista_progetti_categoria/1"&gt;&lt;strong&gt;Vista progetti&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;/fieldset&gt;'
);

// Add it to the body
$body .= render($fieldset);


That works great for me.

You might want to replace the call to render() above with drupal_render() as it offers a minute performance increase; I tend to use render() for all my calls for this sort of thing for continuity, and so that I don't have to check the type of the data being passed.

In this case, as you know the argument is not a string, you could save yourself the few microseconds and use drupal_render() instead.