Is this possible in XHTML: tags in a title-attribute?

拈花ヽ惹草 提交于 2019-12-24 17:22:36

问题


I got following code in an XHTML-document and every browser saysit is malformed :(

<a      class="tooltip" 
        title="Um nach einem <b>Datensatz zu suchen</b>, k&ouml;nnen Sie mehrere 
                Suchbegriffe auf einmal eingeben!<br />
                Um <b>Zeilen zu l&ouml;schen</b>, selektieren Sie diese bitte und 
                klicken dann auf <i>'Zeile(n) l&ouml;schen'</i>.<br />
                Um <b>einen Datansatz zu bearbeiten</b>, klicken Sie einfach zweimal 
                auf die Zelle und dann auf <i>'Done'</i>.<br />
                Um <b>eine Zeile hinzuzuf&uuml;gen</b>, klicken Sie auf <i>'Zeile 
                hinzuf&uuml;gen'</i>. Anschlie&szlig;end k&ouml;nnen Sie diese direkt
                editieren"
>
    <img src="img/info.png" width="35px" height="35px" id="fernglas" />
</a>

Now, is it malformed or not? If so, how could I make it right? Thnx in advance

... dg


回答1:


You can indeed use HTML character entities in the title attribute of a tag. However, you are trying to use HTML tags, which does not appear allowed. You won't be able to use things like bold and italics, but you will be able to add line breaks and some other simple formatting.




回答2:


You could reach that effect by using JavaScript, just display div with position absolute etc ;)




回答3:


You would have to entity encode the content within the title attribute. However the browser will not parse the attribute for HTML markup.




回答4:


I assume you're reading or rendering that title through a script?
If so, just replace every < with &lt; and every > with &gt; and unescape it later.



来源:https://stackoverflow.com/questions/1362158/is-this-possible-in-xhtml-tags-in-a-title-attribute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!