Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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> 
like image 418
Jitendra Vyas Avatar asked Oct 22 '09 06:10

Jitendra Vyas


People also ask

Is IMG valid in HTML?

<img>: The Image Embed element. The <img> HTML element embeds an image into the document.

What is the use of IMG tag in the web page?

The <img> tag is used to embed an image in an HTML page. Images are not technically inserted into a web page; images are linked to web pages. The <img> tag creates a holding space for the referenced image.


2 Answers

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

like image 125
Greg Avatar answered Nov 06 '22 14:11

Greg


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> 
like image 21
Max Avatar answered Nov 06 '22 15:11

Max