caninclude icon indicating copy to clipboard operation
caninclude copied to clipboard

Can <img> tag be within <a> tag?

Open christosptr opened this issue 3 years ago • 3 comments

This website is amazing and looking to use it more as a reference

Please correct if I am wrong. Based on the HTML standards I believe this is a valid HTML

<a href="default.asp">
   <img src="smiley.gif" alt="HTML tutorial">
</a>

When I check this I get a message "I doubt" https://caninclude.glitch.me/can/include/?child=img&parent=a

is this something that can be updated?

Thank you!

christosptr avatar Oct 22 '21 01:10 christosptr

Hi, @christosptr ! Thank you for your feedback!

Since the content model of the <a/> tag is transparent, which means that to decide if the <img/> tag can be included in the <a/> tag, you need to look at the parent of the <a /> tag. For example:

<div>
    <a href="default.asp">
       <img src="smiley.gif" alt="HTML tutorial">
    </a>
</div>

We can include the <img /> tag inside the <div /> because the Flow Content matches https://caninclude.glitch.me/can/include/?child=img&parent=div

But the caninlude service has no information about the parent of the parent, in which case the service shows "I doubt" More context is needed to decide whether to include a tag in a tag in this case.

CyberLight avatar Oct 26 '21 04:10 CyberLight

@CyberLight Thank you very much for the clarification. Is there a way to check if tags are transarent or not and maybe provide this feedback so when some one check they can be pointed to the documentation or what to check?

christosptr avatar Oct 26 '21 12:10 christosptr

Can't Phrasing content be assumed as always allowed for nesting inside elements with Transparent content model? Are there any exceptions?

SelenIT avatar Dec 08 '21 21:12 SelenIT