/    Sign up×
Community /Pin to ProfileBookmark

HTML 4.01 Almost Strict Question.

I’m only getting 2 errors from the w3c validator. Both are form input related.

How do I fix these two errors? Am I not allowed to have hidden form input elements within a div?

[CODE]<form method=”post” action=”newsletter/add.php”>
<div id=”email_focus”><input type=”text” id=”email_input” value=”Your Email Address”></div>
<input type=”hidden” value=”Newsletter”>
<input type=”hidden” value=”text”>
<div id=”email_submit”>
<div id=”email_subscribe”>Subscribe</div>
<input type=”image” src=”submit.png” id=”email_image”></div>
</form>[/CODE]

to post a comment
HTML

4 Comments(s)

Copy linkTweet thisAlerts:
@FangAug 30.2007 — They are not in a div, they must be in a block element; div, fieldset, p ...
Copy linkTweet thisAlerts:
@aj_nscAug 30.2007 — Ok, i seem to recall having a problem like this and I am pretty sure this is what is wrong (I've tried reading through the HTML 4.01 strict specification for the form element but I am not the best at intepreting it):

The control elements of a form (the <input stuff, for example) must be contained within block level elements within a form itself.

Basically, you need to surround everything within the form tags in a div or some block level tag, HTML 4.01 won't let you have <input> elements nested directly inside a <form> without them being nested inside some block level elements first.....This seems to alleviate the problem when you run it through the validator anyway. Other people can explain the reationale behind it better I guess, not me.
Copy linkTweet thisAlerts:
@sridharrAug 30.2007 — I tried with this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Test</title>

</head>

<body>

<form method="post" action="newsletter/add.php">

<div id="email_focus"><input type="text" id="email_input" value="Your Email Address"></div>

<div id="hidden_fld"><input type="hidden" value="Newsletter">

<input type="hidden" value="text"></div>

<div id="email_submit">

<div id="email_subscribe">Subscribe</div>

<input type="image" src="submit.png" id="email_image"></div>

</form>

</body>

</html>
[/QUOTE]


It worked.

I just put the hidden fields within another div.

Another thing, wouldn't you need a name / id for the hidden fields??

Regards,

Sridhar
Copy linkTweet thisAlerts:
@FangAug 30.2007 — If you intend using them to sent data to the server, yes.

btw input type image should have an alt attribute
×

Success!

Help @robindean spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...