Question

Pouvons-nous placer < img > dans < h1 > conformément aux normes Web? comme ça

<h1> Demo text <img src="anyimage.jpg"/> </h1>
Était-ce utile?

La solution

Oui, vous pouvez: la DTD indique:

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

Cela signifie fondamentalement que h1 peut contenir % Inline , composé de plusieurs éléments, dont img

.

Autres conseils

Regardez qui l'utilise: 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>

Oui, cela est autorisé. Mais n'oubliez pas de définir l'attribut alt sur img !

.

Oui et non.

Vous pouvez placer une image dans un élément h1, mais pas tout à fait comme ça & # 8230; l'attribut alt est obligatoire.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top