简体   繁体   中英

HTML Validation

1. there is no attribute 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).

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. If you received this error when using the element to incorporate flash media in a Web page, see the FAQ item on valid flash.

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. 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. 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. Unfortunately I can't help you further because I don't know what is your current Doctype and what elements you are using. 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. That's invalid, because there is no such thing as a key attribute.

From the HTML 4.01 spec , valid attributes on input elements are ( key is not on the list):

<!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 .

If you are using that attribute to store arbitrary data (for use in JavaScript for example), I would recommend using the data-* attributes instead:

<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. You could rename the attribute to data-key . This would be accessible via 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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