xhtml1-strict error

The following code is giving error in W3C validator.
Doctype is “xhtml1-strict”

<form method=“get” action=“#”>
<input type=“text” value=“Search Here or Enter Card No” class=“searchbox” />
<button>Go</button>
</form>

How can i fix this error please help.

Under the strict DTDs ( html 4.01 strict, xhtml 1.0 strict, html 4 strict) and xhtml 1.1, FORM can contain only block level elements directly inside it. But in transitional you can use inline elements too. So, as others said, you have to wrap them in a block level element.

But do not use <p> as a container for form controls; that is semantically wrong. <p> should be used only to contain the paragraph of text.

Thanks… Its works

Jeetendra

Hi jeetendrapal, welcome to SitePoint! :slight_smile:

You should tell us the errors.

Anyhow, I can see one error: you need to enclose your input and button elements in block level elements, such as <p> or <div>. E.g.

[COLOR="Red"]<p>[/COLOR]<input type="text" value="Search Here or Enter Card No" class="searchbox" />[COLOR="Red"]</p>[/COLOR]
[COLOR="Red"]<p>[/COLOR]<button>Go</button>[COLOR="Red"]</p>[/COLOR]

Sorry should have been more explicit

<form method="get" action="#">
<fieldset>
<input type="text" value="Search Here or Enter Card No" class="searchbox" />
<button>Go</button>
</fieldset>
</form>

Wrap the <input> tag in a <fieldset> tag.

I get error free using by <fieldset> tag.

Thanks!
Jeetendra

<fieldset> is probably the most appropriate wrapper with <div> as the next best alternative. One wrapper around all the form fields is sufficient unless you have a reason to want to wrap them separately.