document type does not allow element "div" here

Discussion in 'CSS' started by mrcountry, Mar 19, 2008.

  1. #1
    Please help with this error.

    document type does not allow element "div" here; missing one of "object", "ins", "del", "map", "button" start-tag.

    Below is the actual coding

    <p>
    <label>
    <div style="align:center ">
    <input type="submit" name="Submit" id="Submit" value="Submit" />
    </div>
    </label>
    </p>

    This is the coding for my estimate form submit
     
    mrcountry, Mar 19, 2008 IP
  2. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Before you go any further in your validating:

    Almost every tag in HTML is considered by browsers in default as either two things: blocks, which stack on top of each other and make a newline, and inline, which simply flows from side to side (there are other types like "flow" but we'll ignore them).
    You can change stuff into something else using CSS: for instance, an image is normally inline but you can set it to display: block to make it behave as a block. it is however actually still an inline.

    Blocks can hold blocks, and they can hold inlines. Sometimes a block can only hold another block, and that second block can then carry the inline. Inlines, however, can generally only hold other inlines. Like, a bucket can hold another bucket OR it can hold water, but water can't hold a bucket.

    A label is an inline. You've got it trying to hold a div.

    A form should generally be like this:
    
    <form>(which is a block that must container another block and cannot be nested (no form in a form))
    <fieldset>(block I think... if you use it with XHTML, you must also have a legend)
    <legend> (inline)
    (in place of fieldset/legend you can have another block such as a div)
    <label for="something">Thing 1</label>
      <input type="text" name="something" id="something"  />(XHTML ending only)
    <label for="somethingelse">Thing 2</label>
     <input type="password" name="somethingelse" id="somethingelse" />
    </fieldset>(or div if there was one)
    </form>
    
    Code (markup):
    I also wrap divs around each label-input pair because I've found the div to be handy in clearing floated labels.
     
    Stomme poes, Mar 19, 2008 IP
  3. mrcountry

    mrcountry Active Member

    Messages:
    45
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #3
    I really dont understand what you are trying to say. I am very new to this and i'm having a hard time with this issue. The form works fine it just wont validate because of the highlighted below.

    <p>
    <label>
    <div style="align:center ">
    <input type="submit" name="Submit" id="Submit" value="Submit" />
    </div>
    </label>
    </p>

    This is the complete coding for the form below.

    <div class="story">
    <form method="post" action="formmail.pl">
    <p>
    <input type="hidden" name="recipient" value="rick@countrycustomtile.com" />
    <input type="hidden" name="subject" value="CCT Online Estimate" />
    <input type="hidden" name="redirect" value="http://countrycustomtile.com/" />
    </p>
    <table width="409" border="0">
    <tr>
    <td style="width:106 "><div style="text-align:left " class="style12">First Name</div></td>
    <td style="width:287 "><label>
    <input type="text" name="textfield" id="textfield" /> </label></td>
    </tr>
    <tr>
    <td><div style="text-align:left " class="style12">Last Name</div></td>
    <td><label>
    <input type="text" name="textfield2" id="textfield2" /> </label></td>
    </tr>
    <tr>
    <td><div style="text-align:left " class="style12">Address</div></td>
    <td><label>
    <input type="text" name="textfield3" id="textfield3" /> </label></td>
    </tr>
    <tr>
    <td><div style="text-align:left " class="style12">City</div></td>
    <td><label>
    <input type="text" name="textfield4" id="textfield4" /> </label></td>
    </tr>
    <tr>
    <td><div style="text-align:left " class="style12">State</div></td>
    <td><label>
    <input type="text" name="textfield5" id="textfield5" /> </label></td>
    </tr>
    <tr>
    <td><div style="text-align:left " class="style12">Zip Code</div></td>
    <td><label>
    <input type="text" name="textfield6" id="textfield6" /> </label></td>
    </tr>
    <tr>
    <td><div style="text-align:left " class="style12">Phone</div></td>
    <td><label>
    <input type="text" name="textfield7" id="textfield7" /> </label></td>
    </tr>
    <tr>
    <td style="height:24 "><div style="text-align:left " class="style12">Email</div></td>
    <td><label>
    <input type="text" name="textfield8" id="textfield8" /> </label></td>
    </tr>
    <tr>
    <td style="height:85 "><div style="text-align:left " class="style12">Provide A Brief Description Of The Project.</div></td>
    <td><label>
    <textarea name="textarea" id="textarea" cols="45" rows="5"></textarea>
    </label></td>
    </tr>
    <tr>
    <td style="height:85 "><div style="text-align:left " class="style12">Time Frame For When You Would Like To Start</div></td>
    <td><label>
    <textarea name="textarea2" id="textarea2" cols="45" rows="5"></textarea>
    </label></td>
    </tr>
    <tr>
    <td style="height:22 "><div style="text-align:left " class="style12">Type Of Material</div></td>
    <td><label>
    <input type="radio" name="radio" id="radio" value="radio" />
    <strong>Ceramic</strong> </label></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><label>
    <input type="radio" name="radio2" id="radio2" value="radio2" />
    <strong>Porcelain</strong> </label></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><label>
    <input type="radio" name="radio3" id="radio3" value="radio3" />
    <strong>Natural Stones</strong> </label></td>
    </tr>
    <tr>
    <td><div style="text-align:left " class="style12">Other / Please Specify Below</div></td>
    <td><label>
    <input type="radio" name="radio4" id="radio4" value="radio4" />
    <strong>Other</strong> </label></td>
    </tr>
    <tr>
    <td style="height:28 "><div style="text-align:left " class="style12">Other / Please Specify</div></td>
    <td><label>
    <input type="text" name="textfield9" id="textfield9" /> </label></td>
    </tr>
    <tr>
    <td style="height:37 "><div style="text-align:left " class="style12">Approx Sq Ft Of Floors</div></td>
    <td><label>
    <input type="text" name="textfield10" id="textfield10" /> </label></td>
    </tr>
    <tr>
    <td style="height:37 "><div style="text-align:left " class="style12">Approx Sq Ft Of Walls</div></td>
    <td><label>
    <input type="text" name="textfield11" id="textfield11" /> </label></td>
    </tr>
    <tr>
    <td style="height:37 "><div style="text-align:left " class="style12">Tile Size</div></td>
    <td><label>
    <input type="text" name="textfield12" id="textfield12" /> </label></td>
    </tr>
    <tr>
    <td style="height:37 "><div style="text-align:left " class="style12">Additional Comments</div></td>
    <td><label>
    <input type="text" name="textfield13" id="textfield13" /> </label></td>
    </tr>
    </table>
    <p>
    <label>
    <div style="align:center ">
    <input type="submit" name="Submit" id="Submit" value="Submit" />
    </div>
    </label>
    </p>
    <p style="text-align:center "><strong> <span class="style13">You Will Be Re-Directed To The Home Page</span>&nbsp;</strong> </p>

    </form>

    Highlighted in red is where the problem seems to be as far as the validation. If you can explain this is simple terms what I can do to correct this issue, I would greatly appreciate it.
     
    mrcountry, Mar 19, 2008 IP
  4. Marc Fraser

    Marc Fraser Peon

    Messages:
    283
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Mate, you cant have a <div> within a <p> tag. <div> tags are used to block elements such as <p>'s and therefore thats why you cant put a <p> within it ;).

    The proper code is:

    
    <div style="align:center ">
    <p>
    <label>
    <input type="submit" name="Submit" id="Submit" value="Submit" />
    </label>
    </p>
    </div>
    
    HTML:
    The above should still give you the same output, and it will validate. Good luck!
     
    Marc Fraser, Mar 19, 2008 IP
  5. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #5
    It's just what she said, a label may not have a div child. Here's the definition of label:
    
    <!ELEMENT LABEL - - (%inline;)* -(LABEL) -- form field label text -->
    Code (markup):
    That means the label element must have both opening and closing tags, and may contain only those items identified as %inline (elsewhere in the specs) except that it may not nest another label. The comment says it's a text label for form controls.

    You could get what you want like this (move the style rules to the stylesheet, the inline style attribute is poor practice):
    
    <p style="text-align: center;">
      <label for="lname">Last Name</label>
    </p>
    Code (markup):
    cheers,

    gary
     
    kk5st, Mar 19, 2008 IP
  6. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yup. so, mrcountry there are two problems, one is the div is inside the label, but also the align=center thing... that was all cool and stuff before CSS, but now it's not valid anymore. You'll get some message like "align, no such property" or something.
    You have:
    <label>
    <div><input /></div>
    </label>

    Water (label) is trying to hold the bucket (div).

    I could rewrite your form semantically so it validates, but it won't look as nice as the table without some css, and I dunno if you want a bunch of form-only css (although it works nicely).

    Plus I dunno if your form will still work with that programme you're using if the actual HTML of the form is rewritten.
     
    Stomme poes, Mar 20, 2008 IP