4
\$\begingroup\$

Does my code contain anything invalid?

<form name="myForm" id="myForm">
    <table id="myTab">
        <tr>
            <td>
                <label for="id">User ID:</label>
                <input type="text" id="id" />
            </td>
        </tr>
        <tr>
            <td>
                <label for="pass">Password:</label>
                <input type="password" id="pass" name="pass" />
            </td>
            <td>
                <button type="button" class="submit">Submit</button>
            </td>
        </tr>
        <tr><td><input type="reset" /></td></tr>
    </table>
    <div class="error"></div><div class="correct"></div>
</form>
\$\endgroup\$
  • 2
    \$\begingroup\$ Put your URL here. It will validate the page. \$\endgroup\$ – Martin York Aug 25 '11 at 5:25
  • 3
    \$\begingroup\$ If it's just html, don't / terminate single tags like input \$\endgroup\$ – Alex Aug 25 '11 at 6:37
5
\$\begingroup\$

According to the W3C (http://validator.w3.org/)

Your form tag is not valid.
Technically it must have an action attribute:

required attribute "ACTION" not specified in:
<form name="myForm" id="myForm">

The attribute given above is required for an element that you've used, but you have omitted it.

There are a couple of warnings:

Warning: NET-enabling start-tag requires SHORTTAG YES
<input type="text" id="id" / >
                                    ^^^ <!-- auto closing tag -->

The sequence can be interpreted in at least two different ways, depending on the DOCTYPE of the document. For HTML 4.01 Strict, the '/' terminates the tag '). However, since many browsers don't interpret it this way, even in the presence of an HTML 4.01 Strict DOCTYPE, it is best to avoid it completely in pure HTML documents and reserve its use solely for those written in XHTML.

\$\endgroup\$
2
\$\begingroup\$

Set your first and last <tr> to have colspan="2" so they have the same recognized column count as the second table row. Otherwise it's fine.

I believe it's called XHTML or something when it's XML styling and may need some meta tags, but personally I like the closed tags when they're empty for your error/correct div's below to be <div class="error" /><div class="correct" />, somebody else or a Google could speak to necessity of any doctype tags or other such junk for properly closed tags like that to be recognized as valid by clients.

\$\endgroup\$
  • 1
    \$\begingroup\$ Self-closed <div /> tags aren't handled correctly by many browsers even with an XHTML doctype. \$\endgroup\$ – Peter Taylor Aug 26 '11 at 6:13
1
\$\begingroup\$

Mostly. According to http://validator.nu/:

Warning: A table row was 2 columns wide and exceeded the column count established by the first row (1).
From line 16, column 18; to line 17, column 13
     </td>↩        </tr>↩
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.