Web Analytics Made Easy -
StatCounter <img /> semantics - CodingForum


No announcement yet.

<img /> semantics

  • Filter
  • Time
  • Show
Clear All
new 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
    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 <[[email protected]]>
    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
      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
        <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!