SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,278
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)

    Inlines with blocks

    Simple question: I keep running into the fact that li's (list) are inline elements. However, one of my menus has a sort of submit button inside, which I figure means it needs a form, and the submit itself can't just sit in a form-- it needs either a fieldset or a div or some block around it.

    So I end up with an LI (inline) with a form with a div (a block) inside it. The validator says this is okay apparently (XHTML 1.0 strict) but I can't see how.

    Anyone know? It seems to go against the rules.

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stomme poes View Post
    Simple question: I keep running into the fact that li's (list) are inline elements.
    No, they're not. Although I know Simon disagrees, I consider LI elements to be block-level (he says they're neither). Also, LI elements by default generate block boxes. They are not inline.

    Quote Originally Posted by Stomme poes View Post
    However, one of my menus has a sort of submit button inside, which I figure means it needs a form, and the submit itself can't just sit in a form-- it needs either a fieldset or a div or some block around it.
    That's right. It will be something like this:
    Code HTML4Strict:
    <ul>
      <li>
        <form>
          <div>
            <input>
          </div>
        </form>
      </li>
    </ul>

    Quote Originally Posted by Stomme poes View Post
    So I end up with an LI (inline) with a form with a div (a block) inside it. The validator says this is okay apparently (XHTML 1.0 strict) but I can't see how.
    It's correct, since LI elements aren't inline. According to the HTML 4.01 (and XHTML 1.0) DTDs:
    Code:
    <!ELEMENT LI - O (%flow;)*             -- list item -->
    The %flow; parameter entity expands to all block-level and inilne element types in (X)HTML.
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,278
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    I've been wrestling with %flow again. What the hell is it? It acts like a block but isn't just %block? Why not? What makes %flow different from %block? They seem to ACT the same and they seem to be able to have the same types of children as %blocks...

    Or is it that anything called %block can only have block children? Cause I always thought a div was a block but it's listed as %flow too.

    Right before mentioning %flow, the specs say there are only two kinds of elements, %Blocks and %inlines. Then it says Oh and there's %flow... extremely confusing.

    I don't want to know how to use them, I want to know what they ARE. Some strange mutant hybrid monter form of %block????

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Stomme poes View Post
    I've been wrestling with %flow again. What the hell is it?
    These things are internal entities used within the DTD, to avoid useless repetition. It's like a macro.

    %inline; represents all inline-level element types plus text data.
    %block; represents all block-level element types.
    %flow; means 'block or inline', i.e., all element types that can be used inside body, except some special cases like internal table elements (rows, cells, etc.) that can only exist within a certain parent element type.

    Quote Originally Posted by Stomme poes View Post
    It acts like a block but isn't just %block? Why not? What makes %flow different from %block?
    It's just a shorthand for %inline; OR %block;.

    Quote Originally Posted by Stomme poes View Post
    Or is it that anything called %block can only have block children?
    Some block-level elements (like form and blockquote) can only have block-level children in the Strict DTDs.
    Some (like p) can only have inline-level children or text data.
    Some (like div) can have both (i.e., 'flow' elements).

    Quote Originally Posted by Stomme poes View Post
    Cause I always thought a div was a block but it's listed as %flow too.
    No, the div element type is block-level (it's part of the declaration for the %block; entity). But a div can have %flow; children.

    Code:
    <!ENTITY % block
         "P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |
          BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS">
    Code:
    <!ELEMENT DIV - - (%flow;)*  -- generic language/style container -->
    Quote Originally Posted by Stomme poes View Post
    Right before mentioning %flow, the specs say there are only two kinds of elements, %Blocks and %inlines. Then it says Oh and there's %flow... extremely confusing.
    The %flow; entity means 'block or inline' and is used in those cases when both levels are allowed as children. (Although it's probably not semantically correct to mix them within the same parent.)
    Birnam wood is come to Dunsinane

  5. #5
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,278
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    Okay, this helps a lot... all this time, I've been reading lines like this:
    <!ELEMENT DIV - - (%flow;)* -- generic language/style container -->
    As meaning first the element listed, and then what it was.

    So, the stuff in the ( and ) is what it can contain, not what it is-- that clears up a lot.

    That flow just means "elements" (as elements can only be blocks and inlines) also really clears things up... though I would have just said "elements" then, or "both" to be even clearer...
    <!ELEMENT DIV - - (both;)* -- generic language/style container -->

    Thanks.

  6. #6
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I once wrote The art of reading a DTD, which you may find useful.
    Birnam wood is come to Dunsinane


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
  •