Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Banned
    Join Date
    Jan 2004
    Location
    Minneapolis, MN
    Posts
    387
    Thanks
    0
    Thanked 0 Times in 0 Posts

    <img /> semantics

    i noticed just now upon trying to validate a simple page displaying a new website concept that it is apparently invalid XHTML to have an <img> as the child of the <body>..

    my first thought was that <p><img /></p> doesn't make a lot of sense, so i set the images to display: block and thought i'd be good to go.

    so is there a mental angle to this i'm not quite grasping? i just don't understand why it's REQUIRED to be within' a <p> or something else. i mean, i can kind of see why.. but to me "paragraph" is a term of type layout..

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    If a paragraph is not proper, why not a div? XHTML tends to not allow inline level elements without a block level container element. Another example is that input is not an allowed child of the form element.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    Banned
    Join Date
    Jan 2004
    Location
    Minneapolis, MN
    Posts
    387
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well, is not the <body> considered block level? or neither really? sure, it could be a <div>, but again i say, why not by itself?

  • #4
    me'
    me' is offline
    Senior Coder
    Join Date
    Nov 2002
    Location
    Warwickshire, England
    Posts
    1,229
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <body> can only contain block level elements. <img/> is an inline level element, even if it's told to display block by CSS.
    David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
    W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!


  •  

    Posting Permissions

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