Is it possible to place `<img>` inside `<h1>` according to web standards?

Is it possible to place <img> inside <h1> according to web standards? like this

 <h1> Demo text <img src="anyimage.jpg"/> </h1> 
+45
w3c xhtml xhtml-1.0-strict web-standards
Oct 22 '09 at 6:56
source share
4 answers

Yes you can - DTD :

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

This basically means that h1 can contain %Inline , which consists of various things, including img

+69
Oct 22 '09 at 6:59
source share

See who uses 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> 
+31
22 Oct '09 at 7:20
source share

Yes, it is allowed. But don't forget to set the alt attribute to img !

+13
Oct 22 '09 at 6:58
source share

Yes and no.

You can put the image inside the h1 element, but not quite so ... the alt attribute is required.

+1
Oct 22 '09 at 6:58
source share



All Articles