Technically both as their contained within block level elements, though your IMG element is incorrect on the basis that images don’t have closing tags or text inside
Indeed, I was just about to edit the post and say that this sort of change plays havoc with updates, so I never make changes like this outside the theme folder.
But really, I’d say the easiest solution–if you don’t like the way the pages are rendering–is to tweak your CSS. You should be able to get your images to render any way you like via the stylesheet.
An image by itself isn’t really a paragraph but the alternate text that some people will see instead of the image probably is and so you could probably justify treating an image as a paragraph on that basis.
I tend to wrap images in div tags when needed rather than paragraph tags.
In both the above cases you have inline elements running straight into block level elements and the browser has to step in and create an anonymous block box so that the structure is correct.
Any time you make the browser think then you are asking for trouble in IE and indeed the half finished structure causes many bugs that I see time and time again in the forums and results in missing or misplaced content.
Therefore I always try to ensure that all inline elements are on the same level as other inline elements and that they are contained within a block element before another block element starts.
I prefer to wrap images in paragraph elements because most of the time it makes sense to me and I hate wasting the four extra characters that a div takes. (I see divs as divisions of content rather than containers for individual items although I accept that at times there is no choice.)
If an image in the html then that means it’s important content and saying something to the visitor. When you say something you use paragraphs.
Therefore to avoid bugs in IE and also to be semantically correct I would do this.
I prefer to wrap images in paragraph elements because most of the time it makes sense to me and I hate wasting the four extra characters that a div takes. (I see divs as divisions of content rather than containers for individual items although I accept that at times there is no choice.)
Below code is not correct, there is minor mistake.
<div>
<p><img>MY IMAGE HERE</img><p>
<p>MY PARAGRAPH HERE<p>
</div>
It should be written as below
<div>
<p><img src=“MY IMAGE HERE path” /></p>
<p>MY PARAGRAPH HERE</p>
</div>
Hmm, I’ve been known to wrap the image in an <a> tag and set it to display: block, but I’ll rethink that now:
I do that all the time. If it’s illegal to have inlines and blocks as siblings then I sure would like the W3C to make that rule. After all, they change the rules to make Mozilla happy, so no reason not to do this too
For me I guess it wouldn’t matter if I used <div> or <p> because if I’m wrapping an image, I’m usually floating it anyway, so then the p is required to have a class or id on it because I can’t just float img because the block of the p stops all the cool text wrapping I want. So it’s a bunch of extra characters in any case.
Actually it was a rule in HTML5 before, but that was later changed to allow inline and block as siblings, because most people do that and get confused when it’s suddenly not allowed and it also doesn’t really cause a technical problem to mix them.