W3C home > Mailing lists > Public > www-validator@w3.org > January 2005

Re: <label> in paragraph tag

From: Jukka K. Korpela <jkorpela@cs.tut.fi>
Date: Thu, 20 Jan 2005 08:54:53 +0200 (EET)
To: "David R. Stong" <drs18@psu.edu>
Cc: www-validator@w3.org
Message-ID: <Pine.GSO.4.58.0501200834110.20906@korppi.cs.tut.fi>

On Wed, 19 Jan 2005, David R. Stong wrote:

> - - <label> elements will not
> validate. The Markup Validator says <label> is not allowed in that
> position. If  I nest the form's contents inside a <p></p> tag, then
> place the <form<</form> around the <p></p>, the page validates.

In Strict versions of DTDs, inline markup (or plain text) is not allowed
directly inside a <form> element; everything needs to be wrapped inside a
block level container. It need not be specifically <p>; it could be
<div>, or <fieldset>, for example, or you could have <table> inside a
<form>. Actually using <p> is often not logical, since a <label> and an
<input> don't really form a _paragraph_; moreover, <p> markup implies
typically some default margins, which might be undesired.

> I can't find anything in the DTD or XHTML standard that explains
> this.

In the XHTML 1.0 Strict DTD there is:

<!ELEMENT form %form.content;>

<!ENTITY % form.content "(%block; | %misc;)*">

<!ENTITY % block
     "p | %heading; | div | %lists; | %blocktext; | fieldset | table">

<!ENTITY % misc "noscript | %misc.inline;">

<!ENTITY % misc.inline "ins | del | script">

The Transitional DTD is more permissive as regards to form content:
<!ENTITY % form.content "(#PCDATA | %block; | %inline; | %misc;)*">

The principle of allowing only block level elements directly inside a
<form>, as well as directly inside a <body>, is not explicitly explained
in HTML specifications, even in the good old HTML 2.0 specification (which
also had Strict versions of DTDs and was a great improvement over its
successors in clarity). It is logically independent of the principle of
disallowing (most) presentational elements and attributes, which is what
Strict is best known for.

Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/
Received on Thursday, 20 January 2005 06:55:26 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 1 March 2016 14:17:44 UTC