wp_tag_cloud()
will echo
the tags by default. Because this happens before your return $html;
line, the cloud gets displayed above the shortcode content.
To prevent this, set the echo
arg to false
:
$args = array(
'taxonomy' => 'category',
'echo' => 'false',
);
$tags = wp_tag_cloud( $args );