首页 > 解决方案 > 哪个是使用部分标签的好概念?

问题描述

我想在我的程序中使用部分标签,所以这是在程序内部使用部分标签的正确方法......

<section id="training-pg">
     <div class="row">
       <div class="container">
        // Write you code here.
         <h3>the title</h3>
         <p><?php the_field('training_program'); ?></p>
       </div>
      </div>
    </section>      //  Or 

    <div class="container-fluid">
      <div class="row">
        <section id="training-pg">
          <h3>the title</h3>
          <p><?php the_field('training_program'); ?></p>
        </section>
      </div>
    </div>

标签: javascriptphphtml

解决方案


<select>根据W3Schools的说法,使用的语义方式是:

部分是内容的主题分组,通常带有标题

根据MDN

HTML<section>元素代表一个独立的部分——它没有更具体的语义元素来表示它——包含在 HTML 文档中。通常,但并非总是如此,部分有一个标题。

看到您的第一个示例有一个带有 ID 的部分,该部分清楚地定义了该部分的目的以及标题,我会说:

<section id="training-pg">
    <div class="row">
        <div class="container">
            <h3>the title</h3>
            <p><?php the_field('training_program'); ?></p>
        </div>
    </div>
</section>   

是正确且最符合语义的使用方式<section>


推荐阅读