Max Design

Exciting, engaging websites

  • Home
  • About
  • News
  • Articles
  • Training
  • CSS

Recent Posts

  • Links for light reading (13/10/15)
  • Links for light reading (5/10/15)
  • Links for light reading (21/8/15)
  • Links for light reading (10/8/15)
  • Links for light reading (27/7/15)

Follow

  • Twitter
  • Linkedin
  • Slideshare

Checked inputs and attribute minimization

June 18, 2008 by Russ Weakley

I was recently sent this question:

I tried to use “checked” in an XHTML page. When I validated the page, this showed up as invalid. Why?

Update May 2010: With HTML5, we can now use minimised attributes – called boolean attributes.

Answer:

The use of “checked” in this way is referred to as “attribute minimization”. This means the author has used the attribute’s name but has not specifying a value.

<input name="name" type="checkbox" checked />

For a document to be valid XHTML, attributes cannot be minimized. The W3C XHTML 1.0 spec states:

XML does not support attribute minimization. Attribute-value pairs must be written in full. Attribute names such as compact and checked cannot occur in elements without their value being specified.

http://www.w3.org/TR/xhtml1/#h-4.5

So, the correct way to write this code would be:

<input name="name" type="checkbox" checked="checked" />

Other examples include:

  • checked
  • compact – DEPRECATED
  • declare
  • defer
  • disabled
  • ismap
  • noresize
  • noshade – DEPRECATED
  • nowrap – DEPRECATED
  • selected

Filed Under: Articles

Contact us

  • Facebook
  • GitHub
  • LinkedIn
  • Twitter
© 2016 Max Design

Copyright © 2022 · Parallax Pro Theme on Genesis Framework · WordPress · Log in