Removing divs added by render and node.tpl.php I'm trying to build an HTML5 template for Drupal 7, and I'm quite particular about clean code. I want full control over the HTML and CSS which for the most part I get using my own custom theme. In other words I have an HTML5 and CSS set I want to use exactly as is in Drupal. I'm not too clued up on how the whole pre-process function thing works.

When I use 'print render($page['content'])' in my page.tpl.php file it adds

&lt;div class="region region-content"&gt; 
    &lt;div id="block-system-main" class="block block-system"&gt; 
        &lt;div class="content"&gt;


And then when I add 'print render($content)' in the node--custom.tpl.php it adds

&lt;div class="field field-name-body field-type-text-with-summary field-label-hidden"&gt;
    &lt;div class="field-items"&gt;
        &lt;div class="field-item even" property="content:encoded"&gt;


I don't want any of these divs. How do I get rid of them?
The div ids and classes you see inside $page['content'] comes from region.tpl.php > block.tpl.php > node.tpl.php
Drupal content passes through these template files, each step adds some divs.


Step One


region.tpl.php file contains  the code as follows 

       &lt;?php if ($content): ?&gt;
  &lt;div class="&lt;?php print $classes; ?&gt;"&gt;
    &lt;?php print $content; ?&gt;
  &lt;/div&gt;
&lt;?php endif; ?&gt;


now if you make changes in this file it will effect all the regions of your page. If you want to control only the content area, create a new file name it region--content.tpl.php in that file paste only 

&lt;?php if ($content): ?&gt;

    &lt;?php print $content; ?&gt;

&lt;?php endif; ?&gt;


This will get rid of div created for only content region.


Step Two


Make a copy (if we make changes in block.tpl.php all the blocks will be effected) of block.tpl.php and name it block--content.tpl.php and remove or change the divs. Without the divs the file will contain the following code to output content.

&lt;?php print render($title_prefix); ?&gt;
    &lt;?php if ($block-&gt;subject): ?&gt;
      &lt;h2 class="block-title"&lt;?php print $title_attributes; ?&gt;&gt;&lt;?php print $block-&gt;subject ?&gt;&lt;/h2&gt;
    &lt;?php endif;?&gt;
      &lt;?php print render($title_suffix); ?&gt;
      &lt;?php print $content; ?&gt;


This will get rid of div created by bock.tpl.php 


Step Three


Now edit the node.tpl.php file to remove or change the divs. Without the divs the file will contain the following code to output content.
        
          >">
        

    &lt;?php print $user_picture; ?&gt;

    &lt;?php if ($display_submitted): ?&gt;
      &lt;span class="submitted"&gt;&lt;?php print $date; ?&gt; — &lt;?php print $name; ?&gt;&lt;/span&gt;
    &lt;?php endif; ?&gt;


        &lt;?php
          // We hide the comments and links now so that we can render them later.
        hide($content['comments']);
        hide($content['links']);
        print render($content);
       ?&gt;


    &lt;?php if (!empty($content['links']['terms'])): ?&gt;
      &lt;?php print render($content['links']['terms']); ?&gt;
    &lt;?php endif;?&gt;

    &lt;?php if (!empty($content['links'])): ?&gt;
        &lt;?php print render($content['links']); ?&gt;
      &lt;?php endif; ?&gt;




&lt;?php print render($content['comments']); ?&gt;


This will get rid of all div and classes. Now you can wrap the content with your own divs.  Please let me know if it works for you.