Can we place <img>
inside <h1>
according to web standards? like this
<h1> Demo text <img src="anyimage.jpg"/> </h1>
Can we place <img>
inside <h1>
according to web standards? like this
<h1> Demo text <img src="anyimage.jpg"/> </h1>
Yes, this is allowed. But don’t forget to set the alt
attribute on the img
!
Yes and no.
You can place an image inside an h1 element, but not quite like that … the alt attribute is mandatory.
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
Look who is using it: http://www.w3.org/
<h1 class="logo"><a tabindex="2" accesskey="1" href="/"><img src="/2008/site/images/logo-w3c-mobile-lg" width="90" height="53" alt="W3C" /></a> <span class="alt-logo">W3C</span></h1>