Strange discovery about forms

T

Thomas Mlynarczyk

I just validated a page (HTML 4.01 Strict), but the validator complained
about my <label>, <select> and <input> elements being inside the <form>
element. It seems they must be wrapped in a block-level element such as <p>
or <div>, but I really don't see the sense behind this. Isn't a <form>
element just supposed to contain things like drop down lists, input fields
and buttons? So why must they be wrapped into a superfluous additional
element?

Any enlightenment appreciated.
Greetings,
Thomas
 
K

kayodeok

I just validated a page (HTML 4.01 Strict), but the validator
complained about my <label>, <select> and <input> elements being
inside the <form> element. It seems they must be wrapped in a
block-level element such as <p> or <div>, but I really don't see
the sense behind this. Isn't a <form> element just supposed to
contain things like drop down lists, input fields and buttons?
So why must they be wrapped into a superfluous additional
element?

<input>, <select> and <label> are not block level elements.

http://www.htmlhelp.com/reference/html40/block.html
http://www.htmlhelp.com/reference/html40/inline.html
 
K

Kris

Thomas Mlynarczyk said:
I just validated a page (HTML 4.01 Strict), but the validator complained
about my <label>, <select> and <input> elements being inside the <form>
element. It seems they must be wrapped in a block-level element such as <p>
or <div>, but I really don't see the sense behind this. Isn't a <form>
element just supposed to contain things like drop down lists, input fields
and buttons? So why must they be wrapped into a superfluous additional
element?

Why would an element like <fieldset> be superfluous? I assume you never
heard of it.
 
K

kayodeok

That's true, but what does it have to to with OP's question?

It does seem sensible to expect form elements to be able to go
directly in form, but guess what, they can't. :) form can only
contain block elements, so you can either use divs to hold each
one, or whatever you like.

The Validator is complaining because it expects the OP's elements
to be wrapped in a block element.

I simply pointed out that what the OP refers to as "drop down
lists", "input fields" and "buttons" are inline elements which is
why the validator is complaining.

Perhaps I should have suggested a div or a fieldset but I felt the
links I gave where enough for the OP to make up his mind.
 
T

Thomas Mlynarczyk

Also sprach Kris:
Why would an element like <fieldset> be superfluous? I assume you
never heard of it.

I did. But if there is just one drop down list plus one submit button, does
it still make sense?
 
T

Thomas Mlynarczyk

Thanks for your replies. But I still don't quite understand the "philosophy"
behind it. Why was it considered "better" not to allow inline elements
directly inside a <form> when the standard was developed?
 
K

Kris

Why would an element like <fieldset> be superfluous? I assume you
never heard of it.

I did. But if there is just one drop down list plus one submit button, does
it still make sense?[/QUOTE]

What makes more sense?
A paragraph of text inside a form, marked up as a paragraph..
A collection of multiple labels and form widgets, marked up as such,
using FIELDSET

or

A paragraph of text inside a form, NOT marked up as a paragraph..
A collection of multiple labels and form widgets, NOT marked up as such
 
T

Thomas Mlynarczyk

Also sprach Kris:
What makes more sense?
A paragraph of text inside a form, marked up as a paragraph..
A collection of multiple labels and form widgets, marked up as such,
using FIELDSET

or

A paragraph of text inside a form, NOT marked up as a paragraph..
A collection of multiple labels and form widgets, NOT marked up as
such

Well, in a form element, I would normally expect only those form widgets and
their labels and if anything else is put in there, I would wonder if this is
good use of HTML. Thus, <form> would already fulfill the purpose of
<fieldset>, at least under certain circumstances.
 
T

Thomas Mlynarczyk

Also sprach rf:
Accessibility. Read the spec on the subject, starting here:
http://www.w3.org/TR/html4/interact/forms.html#h-17.10

Then why not make <fieldset> *required*? W3C's validator page uses
<fieldset> outside <form>. If one could add the method, action etc.
attributes to fieldset (or directly to the submit button, where they would
seem more logical anyway), one could even do without <form>. I mean, doesn't
<form> already fulfill in a certain way the function of <fieldset>?
 
S

Steve Pugh

Thomas Mlynarczyk said:
Also sprach rf:


Then why not make <fieldset> *required*? W3C's validator page uses
<fieldset> outside <form>. If one could add the method, action etc.
attributes to fieldset (or directly to the submit button, where they would
seem more logical anyway), one could even do without <form>. I mean, doesn't
<form> already fulfill in a certain way the function of <fieldset>?

How would that work for large forms that are structured with multiple
fieldsets, e.g. a multiple choice quiz with one fieldset around each
queations and its set of options?

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top