SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2009
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    are divs in a fieldset valid?

    I'm using a 4.01 strict dtd.

    Some sources I read say divs in a fieldset are not valid. Or do they mean, specifically a div can't be the first child element, because a legend needs to be the first child?

    So is this valid:
    Code HTML4Strict:
    <fieldset>
                <legend>Shipping Information</legend>
            <div>
            <label for="name">Name:</label>
            <input type="text" id="name" name="name" />
            </div>
     </fieldset>
    ?

  2. #2
    Resident curmudgeon bronze trophy gary.turner's Avatar
    Join Date
    Jan 2009
    Location
    Dallas
    Posts
    990
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In a word, yes. The fieldset may contain anything a div may hold, plus the legend element.

    See Forms in html documents, §17.10 Adding structure to forms: the FIELDSET and LEGEND elements.

    N.B. It is a Good Thing® to learn to read the specs.

    cheers,

    gary
    Anyone can build a usable website. It takes a graphic
    designer to make it slow, confusing, and painful to use.

    Simple minded html & css demos and tutorials

  3. #3
    SitePoint Zealot
    Join Date
    Mar 2007
    Posts
    182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    fieldsets can contain block level elements..a div is a block level element so yes..fieldsets can contain divs and other block level elements..check out xhtml.com..they have a section that shows what an element can contain
    Jaysone


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •