Custom html output of form I want to theme a form in drupal. I know I can add and remove things to the form using hook_form_alter(), change the text etc. Great!

I also want to add some custom html to the form. For example adding a div with some text between two form elements.

I want to do this on the comment form. The comment form has the ID comment_form. So I need to add it to the theme registry.

function mytheme_theme() {
    $items = array();
    $items['comment_form'] = array('comment_form' =&gt; array('arguments' =&gt; array('form' =&gt; NULL)));
    return $items;
}


So I then need to add a function to be called

&lt;?php
  function mytheme_comment_form($form) {
    // stuff goes here
  }
?&gt;


How do I affect the html in this function and render it on the page?
You can add the html in your form_alter, just use '#type' =&gt; 'markup'.