quotes around some attributes in forms

D

dorayme

I have noticed that type=hidden is often written without quotes.
For example see
http://www.scriptarchive.com/readme/formmail.html#recipient who
seems to know what he is talking about. Is this so, or would it
be better practice to use quotes as in type="hidden"? He uses
the quotes on name="" and value="" but not on type="" I have
seen this before I think. Is there any good reason?
 
D

David Dorward

dorayme said:
I have noticed that type=hidden is often written without quotes.
Is this so, or would it be better practice to use quotes as in
type="hidden"?

In certain cases, authors may specify the value of an attribute without
any quotation marks. The attribute value may only contain letters (a-z
and A-Z), digits (0-9), hyphens (ASCII decimal 45), periods (ASCII
decimal 46), underscores (ASCII decimal 95), and colons (ASCII decimal
58). We recommend using quotation marks even when it is possible to
eliminate them.

-- http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2
 
R

rf

dorayme said:
I have noticed that type=hidden is often written without quotes.
For example see
http://www.scriptarchive.com/readme/formmail.html#recipient who
seems to know what he is talking about. Is this so, or would it
be better practice to use quotes as in type="hidden"?

The HTML specs state that attribute values that contain special characters
(those other than alphanumeric and a few others) must be quoted. Attribute
values without special characters don't need to be quoted. Certainly if a
value contains a space it must be quoted.
He uses
the quotes on name="" and value="" but not on type="" I have
seen this before I think. Is there any good reason?

Sloppy coding?

I use quotes for every attribute value rather than relying on remembering
correctly which special characters require quotes.

Additionally, some browsers will accept unquoted values *with* some special
characters. Some browsers will barf on exactly the same value.

1) Don't quote, risk making a mistake that *may not be picked up* in your
test browsers (should be by the validator though) but will break in one of
your viewers browser.

2) Quote everything and be quite safe.

The quotes are required in XHTML anyway, if that ever eventuates.
 
D

dorayme

From: David Dorward said:
In certain cases, authors may specify the value of an attribute without
any quotation marks. The attribute value may only contain letters (a-z
and A-Z), digits (0-9), hyphens (ASCII decimal 45), periods (ASCII
decimal 46), underscores (ASCII decimal 95), and colons (ASCII decimal
58). We recommend using quotation marks even when it is possible to
eliminate them.

-- http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2

OK, so it can be strictly ok not to quote; but best to do anyway
so as not to have to remember which chars actually bring in the
requirement. Thank you DD and rf.
 
N

Neredbojias

With neither quill nor qualm, dorayme quothed:
I have noticed that type=hidden is often written without quotes.
For example see
http://www.scriptarchive.com/readme/formmail.html#recipient who
seems to know what he is talking about. Is this so, or would it
be better practice to use quotes as in type="hidden"? He uses
the quotes on name="" and value="" but not on type="" I have
seen this before I think. Is there any good reason?

I think it's to emphasize that the type is, indeed, hidden.
 

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,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top