列出<li>标签的问题

时间:2016-09-16 18:28:42

标签: html

我已经制作了一个包含<li>标签的列表,如下所示。

https://gyazo.com/764cbe3542522bc552d774e1383ac810

为什么有一个随机<li>标签?根本没有什么可说的吗?

&#13;
&#13;
<center>
    <div class="site-wrapper-inner">
        <div class="cover-container">
            <div class="inner cover" style="text-align:left;margin-top:30px;">
                <div class="card card-outline-primary">
                    <div class="card-header card-primary">
                        Database breaches
                    </div>
                    <div class="card-block">
                        <p>Here is a list of all databases that have been added to our search engine.</p>
                        <li>
                            <p>
                                <?php
                                    $this->load->database();
                                    $this->db->from('databases');
                                    $query = $this->db->get();
                                    foreach($query->result() as $q) {
                                ?>
                                <?=$q->Website?> hacked on
                                <?=$q->Date?> with
                                <?=$q->Users?> users
                                <br />
                                <li>
                                    <p>
                                        <?php 
                                            }
                                        ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</center>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

这是您确切代码的一个版本,但我运行了&#34; tidy&#34;片段中的功能。看看它是如何破碎的?

您没有正确关闭内容,请参阅代码注释。此外,您错误地嵌套了代码,li会在p之前关闭,即使它在它之前开始。

从技术上讲,当您尝试关闭代码时,您正在添加新的li元素,而不是</li>您正在执行<li>

&#13;
&#13;
<center>
  <div class="site-wrapper-inner">
    <div class="cover-container">
      <div class="inner cover" style="text-align:left;margin-top:30px;">
        <div class="card card-outline-primary">
          <div class="card-header card-primary">
            Database breaches
          </div>
          <div class="card-block">
            <p>Here is a list of all databases that have been added to our search engine.</p>
            <li>
              <p>
                <?php $this->load->database(); $this->db->from('databases'); $query = $this->db->get(); foreach($query->result() as $q) { ?>
                <?=$q->Website?> hacked on
                  <?=$q->Date?> with
                    <?=$q->Users?> users
                      <br />
                      <li> <!-- NOT A CLOSING TAG -->
                        <p> <!-- NOT A CLOSING TAG, ALSO SHOULD BE BEFORE THE CLOSING LI TAG -->
                          <?php } ?>
          </div>
        </div>
      </div>
    </div>
  </div>
</center>
&#13;
&#13;
&#13;