How to include different html tags in the header for different pages?

Just assign something to a variable and output that

    if(is_page(14) or is_page(16))
        { $class_name="bannerExp"; }
        if(is_page(18) or is_page(52) or is_page(22) or is_page(20))
        { $class_name="bannerD"; 
          $somevariable="test";
}
        if(is_page(27))
        {$class_name="bannerJ";}
         if(is_page(25))
        {$class_name="bannerS";}
       if(is_page(2))
        {$class_name="bannerH";}

    <div class="<?php echo($class_name);?>">
<?php (if $somevariable != '') { echo $somevariable;} ?>

That being said, this is a horrible way of doing things and you should look into custom page templates, rather than having to check for page id’s and writing if statements for every case scenario… this defeats the point of having a cms.