我们可以根据网络标准在< h1> 中放置< img> 吗?像这样

<h1> Demo text <img src="anyimage.jpg"/> </h1>
有帮助吗?

解决方案

是的,您可以 - DTD 说:

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

这基本上意味着 h1 可以包含%Inline ,它由各种各样的东西组成,包括 img

其他提示

了解谁在使用它: 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>

是的,这是允许的。但是不要忘记在 img 上设置 alt 属性!

是和否。

您可以将图像放在h1元素中,但不完全像那样&#8230; alt 属性是强制性的。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top