Tag-Archiv für 'xhtml'

Collapsing Margins

Dass man am Wochenende die Zeit lieber nicht scriptend vor dem Rechner verbringen sollte, beweißt folgendes Beispiel.
Ich wollte Samstag mal schnell eine kleine Startseite für das trac meines Arbeitgebers zusammenbasteln. Also vom Markup her eigentlich verschwindend gering. Aus dem Code:

<body>
  <div id="head_unit">
     <h1>Header goes here</h1>
     <a href="#">click to open</a>
  </div>  <div id="content_unit">
     <h2>Projekte</h2>    

    <ul>
	<li><a href="">Projekt1</a></li>
    	<li><a href="">Projekt2</a></li>
    	<li><a href="">Projekt3</a></li>
    </ul>
  </div>

<div id="foot_unit">
  </div>
</body>

Soweit so unspannend. Ein paar Zeilen CSS später, schaute ich aber mit fragendem Blick auf meinen Firefox.

‘Collapsing Margins’ weiterlesen

Formulare und inputs

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?