I was once told that the “img” tag in html had to be nested within an element such as the p tag. Is this true? or was mislead?
<p><img src "img/mittromneylittleface.png" alt="drinks" /></p>
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.
Well if you were once told that, you were told this in the context of HTML 4. Take a look at the DTD for HTML 4 Strict here.
You will see that
IMGis an%inlineelement, but the HTMLBODYelement can only contain%block,SCRIPT,INS, andDELelements:So if you want to validate HTML 4 strict, you should definitely include the
IMGinside aPor similar. Try it on a validator, you will see:Now, in HTML 5, you can have an
imgelement right under thebodyelement. Check out the definition of thebodyelement here. It says the content model for thebodyelement is:If you lookup Flow content, you will see that
imgis allowed!