【问题标题】:End Tag for head which is not finished?未完成的头部的结束标签?
【发布时间】:2015-02-20 19:25:26
【问题描述】:

我一直在做一个网站,我们被要求加入 php,并使用页眉/页脚。我的工作没有错误,除了“未完成错误的头部结束标签”我已经将头部的结束标签移动到整个地方并且无法弄清楚为什么它仍然会抛出错误。验证时如何解决这个愚蠢的错误

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="../seltzerr/css/webd2201.css" /> 
        <!--
    Author: Ryan Seltzer 
    Filename: header.php    Date: 2015-02-19    Description: This file is the header for all of my web pages, it includes the styling of the page, colors, banner and all of the links to my other web pages
and will be implemented on future assignments as well.-->
</head>
<body>
<div id="container">
    <div id="header">
    <a href="http://www.durhamcollege.ca">
        <img src="./images/dclogo.jpg" alt="Durham College Logo"/>
        </a>
        <h1>
            Ryan Seltzer's Website
        </h1>
    </div>
    <div id="sites">
        <ul>
            <li><a href="http://opentech.durhamcollege.ca/~pufferd/intn2201/">INTN2201</a></li>
            <li><a href="http://www.w3schools.com">W3Schools</a></li>
            <li><a href="http://validator.w3.org">XHTML Validator</a></li>
            <li><a href="http://jigsaw.w3.org/css-validator/">CSS Validator</a></li>            
            <li><a href="http://php.net/manual/en/index.php">PHP Manual</a></li>
            <li><a href="http://www.durhamcollege.ca">Durham College</a></li>

        </ul>
    </div>
    <div id="content-container">
        <div id="navigation">
            <h3>
                Navigation Bar
            </h3>
            <ul>
                <li><a href="../seltzerr/index.php">Home Page</a></li>
                <li><a href="../seltzerr/lab1.php">Lab 1: Basic XHTML pages</a></li>
                <li><a href="../seltzerr/lab2.php">Lab 2: Working with HTML Tables</a></li>
                <li><a href="../seltzerr/lab3.php">Lab 3: Formatting and Layout with Styles</a></li>
                <li><a href="../seltzerr/termtest1.php">Term Test 1: Practical</a></li>
                <li><a href="../seltzerr/lab4.php">Lab 4: PHP Chapter Files from textbook</a>
                    <ul>
                        <li><a href="../seltzerr/lab4phptags.php">Lab 4: PHP Start and End Tags</a></li>
                        <li><a href="../seltzerr/lab4firstscript.php">Lab 4: PHP Code Cohabitation</a></li>
                        <li><a href="../seltzerr/lab4errorscript.php">Lab 4: PHP Escaping Your Code</a></li>
                        <li><a href="../seltzerr/lab4errorscript2.php">Lab 4: PHP Escaping Your Code Part 2</a></li>
                        <li><a href="../seltzerr/lab4comments.php">Lab 4: PHP Commenting Your Code </a></li>
                        <li><a href="../seltzerr/lab4printvarscript.php">Lab 4: PHP Variable and Value Types</a></li>
                        <li><a href="../seltzerr/lab4constants.php">Lab 4: PHP Using Constants </a></li>
                        <li><a href="../seltzerr/lab4constants2.php">Lab 4: PHP Using Constants 2</a></li>
                        <li><a href="../seltzerr/lab4assignscript.php">Lab 4: PHP Assignment Operators</a></li>
                        <li><a href="../seltzerr/lab4comparisonscript.php">Lab 4: PHP Comparison Operators</a></li>
                        <li><a href="../seltzerr/lab4logicalscript.php">Lab 4: PHP Logical Operators</a></li>
                    </ul>
                </li>
            </ul>
        </div>
        <div id="content"><!--
    Author: Ryan Seltzer 
    Filename: header.php    Date: 2015-02-19    Description: This file is the header for all of my web pages, it includes the styling of the page, colors, banner and all of the links to my other web pages
and will be implemented on future assignments as well.-->
            <h2>Ryan Seltzer's Home         </h2>
            <p>This page was created for the class <a href ="http://opentech.durhamcollege.ca/~pufferd/intn2201">WebD2201</a> 
at <a href="http://www.durhamcollege.ca">Durham College</a> as a home page for
all of the assignments given over the course of this semester. The objective of this
website is to serve as a home page for all of the coming assignments. It will have links
to each assignment done and will follow a similar shape and feel to all assignments.</p>

        <!-- end of main page content -->
        </div>      
        <div id="footer">
        <!-- start of footer -->
                <a href="http://validator.w3.org/check?uri=referer">
                    <img    style="width:88px;
                                height:31px;"
                            src="http://www.w3.org/Icons/valid-xhtml10" 
                            alt="Valid XHTML 1.0 Strict" />
                </a>
                <a href="http://jigsaw.w3.org/css-validator/check/referer">
                        <img    style="width:88px;
                                    height:31px;"
                                src="http://jigsaw.w3.org/css-validator/images/vcss"
                                alt="Valid CSS!" />
                </a>
                &copy; Ryan Seltzer, 2015
        <!-- end of footer -->
        </div>
    </div>
</div>
</body>
</html>

【问题讨论】:

  • 是什么给了你这个错误?你在哪里看到的?
  • 它在 w3 验证器中显示第 11 列第 7 行
  • PHP解析完后能显示源码吗?
  • “我的工作没有错误” + “无法弄清楚为什么它仍然会抛出错误” - 你在自相矛盾。另外,&lt;?php $title ?&gt; 应该做什么?这只是一个处于不确定状态的变量。你的文件是.php,对吧?
  • 渲染时 php var $title 会产生什么?

标签: php xhtml


【解决方案1】:

您的问题是该页面没有&lt;title&gt; 元素。这是必需的。

最好的办法是将您的代码放入http://validator.w3.org/,它通常会为您提供有关问题所在的有用信息。

在这种情况下,它将显示...

blah blah blah 另一种可能性是您使用了一个需要孩子的元素 您未包含的元素。因此父元素是“不是 完成”,不完整。例如,在 HTML 中,&lt;head&gt; 元素必须 包含&lt;title&gt; 子元素,列表需要适当的列表项等等等等

【讨论】:

  • 我确实把它放在了 w3 中,它给出了那个无用的错误。我将删除标准 的 $title 并查看它是否修复。
  • 我编辑了我的答案以包含错误消息的一部分,它甚至特别提到了标题元素(我想这是一个常见问题)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-07
  • 2018-10-31
  • 1970-01-01
  • 2014-04-22
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多