XHTML 严格 1.0 .无限错误



我已经检查了我的XHTML严格1.0代码,我遇到了很多错误 验证器:validator.w3.org 请您帮助我修复错误

法典:

<!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" lang="en" xml:lang="en"> <head>
    <title>  my trip around the US on my very own Segway </title>
 </head>
  <body>
    <h1> Segway'n USA </h1>
    <p>
      Documenting my trip around the US on my
very own Segway
    </p>
    <h2> August 20, 2005 </h2>
    <img src="images/segway2.jpg"/ alt="segway"/>
    <p>
      Well I made it 1200 miles already, and I passed
       through some interesting places on the way:
   </p>
   <ol> <!-- ordered list -->
<li>Walla Walla, WA</li>
<li>Magic City, ID</li>
<li>Bountiful, UT</li>
<li>Last Chance, CO</li>
<li>Why, AZ</li>
<li>Truth or Consequences, NM</li>
    </ol>
    <h2> July 14, 2005 </h2>
    <p>
      I saw some Burma Shave style signs on the side of the
       road today :
    </p>
    <blockquote>
Passing cars,
When you can't see, May get you,
A glimpse,
Of eternity.
    </blockquote>
    <p>
      I definitely won't be passing any cars.
    </p>
    <h2> June 2, 2005 </h2>
    <img src="images/segway1.jpg"/ alt="segway">
    <p>
      My frst day of the trip! I can't believe I fnally got
       everything packed and ready to go. Because I'm on a Segway,
       I wasn't able to bring a whole lot with me: cellphone, iPod,
       digital camera, and a protein bar. Just the essentials. As
       Lao Tzu would have said, <q>A journey of a thousand miles begins
       with one Segway</q>
    </p>
  </body>
  </html>

完整代码链接 : http://pastebin.com/L95bt2Yu

谢谢大家

不要先使用验证器(先使用 XML 解析器),也不要使用旧版本的 XHTML。您应该将HTML5用于HTML和XHTML用于XML解析器,这将立即捕获大约80%的渲染错误并简化您的开发。所以这意味着使用XHTML5可以两全其美。要使用HTML5,您需要使用HTML5元素。要使用 XML 解析器,您需要将页面作为application/xhtml+xml提供。在本地,您需要保存扩展名为.xhtml的文件。不要让对XHTML的压倒性消极态度破坏XML解析器的有用性,最好的使用最好的工具,当他们犯错时忽略大众。只要你把它与HTML5结合使用,那么你就会做你能做的最多的事情,这使你远远领先于大多数人。

对于服务器,您需要进行内容协商。当你到达PHP时,在发送非头数据(例如任何HTML/echo之前使用以下方法:

if (stristr($_SERVER['HTTP_ACCEPT'],'application/xhtml+xml'))
{
 header('Content-Type: application/xhtml+xml');
}

在你达到这一点之前,使用像WinMerge这样的程序来确定整个页面的代码有何不同,直到你能够缩小它的范围。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>XHTML5 Example</title>
<meta name="description" content="Manage domain accounts." />
<meta name="keywords" content="example" />
<meta name="language" content="en" />
<meta name="robots" content="noarchive, noindex, nofollow" />
<base href="https://localhost/" />
<link href="blog/rss/" rel="alternate" title="Blog RSS Feed" type="application/rss+xml" />
<link href="favicon.ico" rel="icon" />
<script defer="defer" src="scripts/index.js" type="application/javascript"></script>
</head>
<body>
<h1><span>Example Header, use h1 element only once per page</span></h1>
<main>
 <p>Example paragraph.</p>
<ol>
 <li><span>Bullet One</span></li>
 <li><span>Bullet Two</span></li>
 <li><span>Bullet Three</span></li>
</ol>
<ul>
 <li><span>Bullet</span></li>
 <li><span>Bullet</span></li>
 <li><span>Bullet</span></li>
</ul>
<blockquote>
 <p>The <code>blockquote</code> element may contain block-level elements.
 The <code>q</code> element may only contain inline elements.</p>
</blockquote>
</main>
<aside>
<img alt="Alternative text displayed only if image does not load" src="example.png" />
</aside>
</body>
</html>

最新更新