Is it allowed to use other tags inside <title>?

半世苍凉 提交于 2019-12-04 00:22:26

问题


Is it correct practice or valid syntax to use other tags inside a <title>?

An example for multi-language title

<html lang=en>
<title>Some title in English and a <i lang=fr>word in French</i></title>

回答1:


See http://www.w3.org/TR/html401/struct/global.html#h-7.4.2:

Titles may contain character entities (for accented characters, special characters, etc.), but may not contain other markup (including comments).

(my emphasis)




回答2:


No, it may not

http://www.w3.org/Provider/Style/TITLE.html




回答3:


You can try to use whatever you want, but it will all be used as title string, without any additional parsing/processing from the browser (if that's what you expect). RFC says you have to resist from placing markup in title, though.




回答4:


TLDR: The <title> tag (1) must contain text (it must not be empty), (2) must only contain text (i.e. no other elements), and (3) must contain text that is not just white-space.


In HTML 5, the Content Model of the title element is:

Text that is not inter-element white space.

where inter-element white space is any Text node that is either empty or only contains sequences of space characters:

  • U+0020 SPACE
  • U+0009 CHARACTER TABULATION (tab)
  • U+000A LINE FEED (LF)
  • U+000C FORM FEED (FF)
  • U+000D CARRIAGE RETURN (CR)


来源:https://stackoverflow.com/questions/12168806/is-it-allowed-to-use-other-tags-inside-title

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