简体   繁体   English

HTML验证

[英]HTML Validation

My website is almost ready but I notice that my website shows in Firefox and IE look different and in chrome is fine. 我的网站几乎已准备就绪,但我注意到我的网站在Firefox和IE中显示的外观有所不同,在chrome中也可以。 I have used HTML Validation to check and have 2 errors and 2 warnings. 我已经使用HTML验证进行检查,并且有2个错误和2个警告。 This is the details : 这是细节:

 Line 2, Column 13: there is no attribute "XMLNS"
 <html xmlns="http://www.w3.org/1999/xhtml">

You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. 您已经在文档中使用了上面命名的属性,但是您正在使用的文档类型不支持该元素的该属性。 This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (eg you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead). 此错误通常是由于使用框架的文档未正确使用“严格”文档类型(例如,必须使用“过渡”文档类型来获取“目标”属性)或使用供应商专有扩展名(例如“ marginheight”(通常通过使用CSS来实现所需的效果来解决此问题)。

This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; 如果所使用的文档类型不支持该元素本身,也可能导致此错误,因为未定义的元素将不具有支持的属性; in this case, see the element-undefined error message for further information. 在这种情况下,请参阅元素未定义的错误消息以获取更多信息。

How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. 解决方法:检查元素和属性的拼写和大小写(记住XHTML均为小写)和/或检查所选文档类型是否都允许它们,和/或使用CSS代替此属性。 If you received this error when using the element to incorporate flash media in a Web page, see the FAQ item on valid flash. 如果在使用元素将Flash Media合并到网页中时收到此错误,请参阅有效Flash上​​的FAQ项。

 Line 4, Column 76: NET-enabling start-tag requires SHORTTAG YES
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

For the current document, the validator interprets strings like according to legacy rules that break the expectations of most authors and thus cause confusing warnings and error messages from the validator. 对于当前文档,验证器按照遗留规则来解释字符串,这会破坏大多数作者的期望,从而导致验证器产生混乱的警告和错误消息。 This interpretation is triggered by HTML 4 documents or other SGML-based HTML documents. HTML 4文档或其他基于SGML的HTML文档触发了这种解释。 To avoid the messages, simply remove the "/" character in such contexts. 为避免出现此消息,只需在这种情况下删除“ /”字符即可。 NB: If you expect to be interpreted as an XML-compatible "self-closing" tag, then you need to use XHTML or HTML5. 注意:如果您希望将其解释为与XML兼容的“自动关闭”标签,则需要使用XHTML或HTML5。

This warning and related errors may also be caused by an unquoted attribute value containing one or more "/". 此警告和相关错误也可能由包含一个或多个“ /”的未引用属性值引起。 Example: http://w3c.org>W3C. 示例:http://w3c.org> W3C。 In such cases, the solution is to put quotation marks around the value. 在这种情况下,解决方案是在值周围加上引号。

 Line 4, Column 77: character data is not allowed here
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

You have used character data somewhere it is not permitted to appear. 您在不允许出现的地方使用了字符数据。 Mistakes that can cause this error include: 可能导致此错误的错误包括:

putting text directly in the body of the document without wrapping it in a container element (such as a 将文本直接放在文档主体中,而无需将其包装在容器元素中(例如

aragraph aragraph

), or forgetting to quote an attribute value (where characters such as "%" and "/" are common, but cannot appear without surrounding quotes), or using XHTML-style self-closing tags (such as ) in HTML 4.01 or earlier. ),或者忘记用引号引起来的属性值(“%”和“ /”之类的字符很常见,但没有引号就不能出现),或者在HTML 4.01或更早版本中使用XHTML样式的自动关闭标签(例如) 。 To fix, remove the extra slash ('/') character. 要解决此问题,请删除多余的斜杠('/')字符。 For more information about the reasons for this, see Empty elements in SGML, HTML, XML, and XHTML. 有关原因的更多信息,请参见SGML,HTML,XML和XHTML中的Empty元素。

  Line 44, Column 12: NET-enabling start-tag requires SHORTTAG YES <br/> 

For the current document, the validator interprets strings like according to legacy rules that break the expectations of most authors and thus cause confusing warnings and error messages from the validator. 对于当前文档,验证器按照遗留规则来解释字符串,这会破坏大多数作者的期望,从而导致验证器产生混乱的警告和错误消息。 This interpretation is triggered by HTML 4 documents or other SGML-based HTML documents. HTML 4文档或其他基于SGML的HTML文档触发了这种解释。 To avoid the messages, simply remove the "/" character in such contexts. 为避免出现此消息,只需在这种情况下删除“ /”字符即可。 NB: If you expect to be interpreted as an XML-compatible "self-closing" tag, then you need to use XHTML or HTML5. 注意:如果您希望将其解释为与XML兼容的“自动关闭”标签,则需要使用XHTML或HTML5。

This warning and related errors may also be caused by an unquoted attribute value containing one or more "/". 此警告和相关错误也可能由包含一个或多个“ /”的未引用属性值引起。 Example: http://w3c.org>W3C. 示例:http://w3c.org> W3C。 In such cases, the solution is to put quotation marks around the value. 在这种情况下,解决方案是在值周围加上引号。

As for Line 2, Column 13, I have added in this under header.php: 至于第2行,第13列,我在header.php下添加了它:

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en-US" xmlns="http://www.w3.org/1999/xhtml"> 

However, this error is still there and I really do not know how to tidy it. 但是,此错误仍然存​​在,我真的不知道如何解决它。 On top of that, I am not a programmer and very poor in HTML.... 最重要的是,我不是一名程序员,而且HTML很差。

Thank you. 谢谢。

You are trying to validate a document with some XHTML features as HTML 4. You are not showing the first line of the HTML document, and this would be all-important. 您试图用XHTML特性验证具有某些XHTML功能的文档。您没有显示HTML文档的第一行,这很重要。 In general, you should show a complete HTML document that reproduces the issue. 通常,您应该显示一个完整的HTML文档来重现该问题。 But in this case, the apparent reason is wrong DOCTYPE. 但是在这种情况下,明显的原因是DOCTYPE错误。 You should replace the existing HTML 4 DOCTYPE by one that declares some version of XHTML 1.0, if XHTML 1.0 is what you are trying to use. 如果要使用 XHTML 1.0,则应使用声明某些XHTML 1.0版本的HTML 4 DOCTYPE 替换现有的HTML 4 DOCTYPE。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM