w3cweb-standardsxhtml-1.0-strictxhtml

Can we place `<img>` inside `<h1>` according to web standards?


Can we place <img> inside <h1> according to web standards? like this

<h1> Demo text <img src="anyimage.jpg"/> </h1>

Solution

  • Yes, you can - the DTD says:

    <!ELEMENT h1  %Inline;>
    <!ENTITY % Inline "(#PCDATA | %inline; | %misc.inline;)*">
    <!ENTITY % inline "a | %special; | %fontstyle; | %phrase; | %inline.forms;">
    <!ENTITY % special "%special.pre; | object | img ">
    

    That basically means h1 can contain %Inline, which is made of various things, including img