Home >> FAQs/Tutorials >> XHTML Tutorials and Tips >> Index

XHTML Tutorial - The "checked" Attribute

By: FYIcenter.com

(Continued from previous topic...)

What Is Wrong with My "checked" Attribute Values?

Attribute "checked" is an optional attribute for XHTML element "input". In XHTML specification, attribute "checked" has only predefined value: "checked". However, in HTML specification, attribute "checked" requires no value.

If you are converting existing HTML documents to XHTML format, you will get some syntax error on your pre-selected items in radio buttons, check boxes and dropdown lists, "checked" attributes are used without any values.

Here are some interesting examples of "checked" attributes:

  • <input type="radio" name="lang" value="HTML" checked> - Invalid, all attributes must have values. This is valid as HTML documents.
  • <input type="radio" name="lang" value="HTML" checked="yes"> - Invalid, "yes" is not the predefined value of attribute "checked".
  • <input type="radio" name="lang" value="HTML" checked="checked"> - Valid, attribute "checked" is assigned with predefined vlaue "checked".

  1. What Is an XHTML Element?
  2. How To Enter Comments into XHTML Documents?
  3. How To Write the Opening Tag of an XHTML Element?
  4. How To Close an XHTML Element?
  5. What Is Wrong with My <br> Tags?
  6. What Is Wrong with My <meta> Tags?
  7. How To Enter Element Content?
  8. Is XHTML Element Name Case Sensitive?
  9. What Is an XHTML Element Attribute?
  10. How To Write Element Attributes Properly?
  11. Is Attribute Name Case Sensitive?
  12. How To Quote Element Attribute Values Properly?
  13. How To Write Ampersand Sign in Attribute Values?
  14. What Is a Required Attribute?
  15. What Are Predefined Attribute Values?
  16. What Is Wrong with My "checked" Attribute Values?

Selected Developer Jobs: