公告
财富商城
积分规则
提问
发文
2019-01-13 19:39发布
冷血范
Can we place <img> inside <h1> according to web standards? like this
<img>
<h1>
<h1> Demo text <img src="anyimage.jpg"/> </h1>
Yes and no.
You can place an image inside an h1 element, but not quite like that … the alt attribute is mandatory.
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>
Yes, this is allowed. But don’t forget to set the alt attribute on the img!
alt
img
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
h1
%Inline
最多设置5个标签!
Yes and no.
You can place an image inside an h1 element, but not quite like that … the alt attribute is mandatory.
Look who is using it: http://www.w3.org/
Yes, this is allowed. But don’t forget to set the
alt
attribute on theimg
!Yes, you can - the DTD says:
That basically means
h1
can contain%Inline
, which is made of various things, includingimg