SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    eez
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is this bad practice XHTML? (block element coming directly after inline element)

    Hi!

    Is this bad practice XHTML?

    <a href="google.co.uk">Aha!</a>

    <ol>
    <li>...</li>
    ...
    </ol>

    I mean a block-level element coming directly after an inline element. It is valid for the w3 validator in chtml strict mode (I don't trust it a yota though). Thanks!

  2. #2
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's valid, but not how I would do things.

    I'd have the anchor inside a block level element, and then have the list come after that (the block level element, not the anchor).

    For example:
    HTML Code:
    <div>
        <a href="#">Some Link</a>
    </div>
    <ol>
        <li>List Item</li>
        <li>List Item</li>
    </ol>

  3. #3
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    What's wrong with a block element coming after an inline one?

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's a logical oddity. An element should normally contain either block-level elements or inline elements, not both. The HTML spec allows the mix, but it doesn't really make sense (not to me, at least).

    When content like this is rendered by a CSS-compliant user agent, the inline elements will be surrounded by what is called 'anonymous block boxes', because it doesn't make sense to mix block-level and inline content at the same structural level.
    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
  •