XHTML 1.1 Geçerlilik Testi Form Hatası

Sitemi http://validator.w3.org ile xhtml kurallarına uyup uymadığını kontrol ettirdim ve formda 3 tane hata çıktı. Hata kodları label ve form etiketlerindeymiş. Hata kodlarının 2 tanesi aşağıdaki gibi:

  • Line 36, Column 11: document type does not allow element “label” here; missing one of “ins”, “del”, “h1″, “h2″, “h3″, “h4″, “h5″, “h6″, “p”, “div”, “address”, “fieldset” start-tag
  • Line 42, Column 9: end tag for “form” which is not finished

Hata nedeni ise XHTML 1.1′de form elemanlarını fieldset içine almak gerekmesiymiş.

Aşağıya eski kodu ve hatanın düzeltilmiş hali olan yeni kodu yazıyorum.

  Hatalı Kod:

<form id=”form1″ method=”post” action=”">
    <label>
    <input name=”textfield” type=”text” class=”arama-kutusu” />
    </label>
    <label > <br />
    <input name=”Submit” type=”submit” class=”ara-butonu” value=”Ara” />
    </label>
  </form>

Düzeltilmiş Kod:

  <form id=”form1″ method=”post” action=”">
  <fieldset>
 <label>
    <input name=”textfield” type=”text” class=”arama-kutusu” />
    </label>
    <label > <br />
    <input name=”Submit” type=”submit” class=”ara-butonu” value=”Ara” />
    </label>
  </fieldset>
  </form>

Yorum Yapın