Vor kurzem ist mir aufgefallen das ein simples Login-Formular von mir nicht valide ist. Doctype XHTML 1 strict ist nix neues für mich. Und auch FOrmulare sehe nicht zum ersten mal.
Folgendes Formular sollte den Login ermöglichen:
<form action=”" method=”post” id=”loginForm”>
<label for=”userName”>Benutzername</label><input type=”text” name=”userName” id=”userName” maxlength=”255″ accesskey=”u” tabindex=”1″ /><br />
<label for=”userPW”>Passwort</label><input type=”password” name=”userPW” id=”userPW” maxlength=”255″ accesskey=”p” tabindex=”2″ /><br />
<input type=”submit” value=”Login” name=”submit” id=”submit” tabindex=”3″ />
</form>
Der Validator beschwerte sich aber mit einer Fehlermeldung:
Line 11, Column 136: document type does not allow element “input” here; missing one of “p”, “h1″, “h2″, “h3″, “h4″, “h5″, “h6″, “div”, “pre”, “address”, “fieldset”, “ins”, “del” start-tag.
The mentioned element is not allowed to appear in the context in which you’ve placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you’ve forgotten to close a previous element.
One possible cause for this message is that you have attempted to put a block-level element (such as “<p>” or “<table>”) inside an inline element (such as “<a>”, “<span>”, or “<font>”).
Diese Fehlermeldung kann ich leider nicht ganz nachvollziehen. Für mich sind <form> und <input> bisher direkt von einander abhängige Elemente gewesen. Ohne <input> macht ein Form wenig Sinn und andersrum genauso. Setze ich jetzt als ein <div>, <p> oder <fieldset> darum gibt der Validator Ruhe. Das <fieldset> kann aufgrund seiner gruppierenden Funktion noch nachvollziehen. Aber der Rest? Soll ich jetzt den Quellcode aufblähen nur damit der Validator Ruhe gibt?
zuletzt kommentiert