View Full Version : <img /> semantics

02-27-2004, 10:20 PM
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..

02-28-2004, 06:39 AM
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.

02-28-2004, 09:15 AM
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?

02-28-2004, 10:42 AM
<body> can only contain block level elements. <img/> is an inline level element, even if it's told to display block by CSS.