Multiple <head> and <body> tag

前端 未结 3 1617
甜味超标
甜味超标 2021-01-20 19:57

I am trying to create a very simple web application, basically to understand the best practices of coding in HTML5, CSS and JavaScript.

My application has 3-4 pages

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-20 20:13

    Another possible solution to avoid multiple head tags which also makes it possible to add additional css files:

    
      
      
        {$title}
        {$meta}
        
        {$additional_style}
      
      
        
        {$mainbody}
        {$footer}
        {$javascript}
      
      
    EOF;
    ?>
    
    
    
    ';
    $mainbody = 'your body';
    $footer = '';
    $javascript = '';
    
    include_once("head.php");
    echo $html;
    ?>
    

    It also allows for multiple levels of inheritance (for example, you could define the same footer for a couple of pages). This principle can also be used without EOF, but I think that it looks nicer this way.

    The main downside is that you will get a warning if you do not set all the variables of head.php in the pages including it.

提交回复
热议问题