Should the <img> tag be wrapped in a <p> tag or can it be just used without a <p> tag?
Should the <img> tag be wrapped in a <p> tag or can it be
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I can’t comment or vote yet, but the answer by Younes is wrong. You cannot write an image tag like this:
Also, the best place to look for what is allowed and not allowed for HTML tags, the best source is the actual specs, available on the W3C website. Here’s the link for the img tag for HTML 4.01:
http://www.w3.org/TR/html4/struct/objects.html#h-13.2
And here’s the link showing the differences between HTML 4.01 and XHTML 1.0 (which is where the comes from:
http://www.w3.org/TR/xhtml1/#diffs
In general, an img can be wrapped by most container tags (some exceptions, like pre, do exist), but it is not required. If you are trying to make your HTML semantic, then most often, it won’t make sense to have your img inside a paragraph tag, but it might make sense to put it into a div.