简体   繁体   English

HTML验证

[英]HTML Validation

1. there is no attribute X 1.没有属性X

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 335, column 52: there is no attribute "key"

…t type="text" value="Full Name:"  key="Full Name:" name="txtFullName" id="txtF…

Line 341, column 78: there is no attribute "value"

…"txtMessage" cols="22" rows="3" value="Project" style="color:#707070;" class="…

I have checked my HTML but unable to find solution. 我已经检查了HTML,但找不到解决方案。 Can any one guide me what should be the possible solution of this problem. 谁能指导我该问题的可能解决方案。 Can some one explain? 有人可以解释吗?

As I understand you use attribute "key" (key="Full Name:") that is not in HTML specifications. 据我了解,您使用HTML规范中没有的属性“ key”(key =“ Full Name:”)。 Remove it and it will be ok. 删除它就可以了。

You have to check your Doctype. 您必须检查您的文档类型。 If you assign the correct Doctype then you will solve your problem. 如果您分配了正确的Doctype,那么您将解决问题。 Unfortunately I can't help you further because I don't know what is your current Doctype and what elements you are using. 不幸的是,我无法进一步为您提供帮助,因为我不知道您当前的Doctype是什么以及您使用的是什么元素。 Give me the web page to pass the validation and I will give you a solution. 给我网页通过验证,然后给您解决方案。

By the look of the output from the validator, it appears that you have a key attribute on what looks likely to be an input element. 从验证器的输出看,您似乎对可能是input元素的内容具有key属性。 That's invalid, because there is no such thing as a key attribute. 这是无效的,因为没有诸如key属性之类的东西。

From the HTML 4.01 spec , valid attributes on input elements are ( key is not on the list): 根据HTML 4.01规范input元素上的有效属性为( key不在列表中):

<!ATTLIST INPUT
  %attrs;                              -- %coreattrs, %i18n, %events --
  type        %InputType;    TEXT      -- what kind of widget is needed --
  name        CDATA          #IMPLIED  -- submit as part of form --
  value       CDATA          #IMPLIED  -- Specify for radio buttons and checkboxes --
  checked     (checked)      #IMPLIED  -- for radio buttons and check boxes --
  disabled    (disabled)     #IMPLIED  -- unavailable in this context --
  readonly    (readonly)     #IMPLIED  -- for text and passwd --
  size        CDATA          #IMPLIED  -- specific to each type of field --
  maxlength   NUMBER         #IMPLIED  -- max chars for text fields --
  src         %URI;          #IMPLIED  -- for fields with images --
  alt         CDATA          #IMPLIED  -- short description --
  usemap      %URI;          #IMPLIED  -- use client-side image map --
  ismap       (ismap)        #IMPLIED  -- use server-side image map --
  tabindex    NUMBER         #IMPLIED  -- position in tabbing order --
  accesskey   %Character;    #IMPLIED  -- accessibility key character --
  onfocus     %Script;       #IMPLIED  -- the element got the focus --
  onblur      %Script;       #IMPLIED  -- the element lost the focus --
  onselect    %Script;       #IMPLIED  -- some text was selected --
  onchange    %Script;       #IMPLIED  -- the element value was changed --
  accept      %ContentTypes; #IMPLIED  -- list of MIME types for file upload --
  >

Nor is key a valid attribute according to the current version of the HTML living standard . 根据HTML生存标准的当前版本, key也不是有效的属性。

If you are using that attribute to store arbitrary data (for use in JavaScript for example), I would recommend using the data-* attributes instead: 如果使用该属性存储任意数据(例如,用于JavaScript),则建议使用data-*属性代替:

<input type="text" data-key="Whatever you like">

You can not have attributes that are not in the spec as metioned here, but if you use the HTML5 doctype, you can have any attributes with a data- prefix. 您不能具有此处未提及的规范中未包含的属性,但是如果使用HTML5文档类型,则可以具有带有data-前缀的任何属性。 You could rename the attribute to data-key . 您可以将属性重命名为data-key This would be accessible via Javascript. 这可以通过Javascript访问。

If you cannot use the HTML5 doctype, then you could use a hidden field with a similar name as the textbox, such as `txtFullNameHidden' to store the key. 如果不能使用HTML5文档类型,则可以使用与文本框名称相似的隐藏字段,例如“ txtFullNameHidden”来存储密钥。

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

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