XHTML - What elements are allowed within the e

2019-01-26 03:58发布

I know span strong and em. Are there any others? I'm trying to filter a text which goes inside a link, and need to know what elements should I leave unfiltered?

5条回答
Bombasti
2楼-- · 2019-01-26 04:16

Other inline tags should be legal inside <a> like <img>, <abbr>, etc. Here's alist of all the inline tags:

http://en.wikipedia.org/wiki/Inline_tag#Inline_elements

Also, since <a> is a body tag, inline body tags only inside it, please.

查看更多
戒情不戒烟
3楼-- · 2019-01-26 04:19

It is worth to mention that "block-level links" are valid in HTML5.

查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-01-26 04:22

If you're using XHTML transitional, then font, b, i, sub, sup....AFAIK just about any inline tag (except for another link) will fit.

查看更多
干净又极端
5楼-- · 2019-01-26 04:25

According to the DTD, lots of elements:

br | span | bdo | map
object | img | tt | i | b | big | small 
ins | del | script | input | select | textarea | label | button
em | strong | dfn | code | q |
               samp | kbd | var | cite | abbr | acronym | sub | sup 
查看更多
看我几分像从前
6楼-- · 2019-01-26 04:39

For HTML 4.01 Transitional, for instance, you can pick the DTD from w3c site. Then search the <!ELEMENT A in the document and navigate the entities, like %inline; to know the allowed nested elements.

  • #PCDATA is allowed.
  • Through %inline; and %fontstyle;: TT | I | B | U | S | STRIKE | BIG | SMALL
  • Through %inline; and %pharse;: EM | STRONG | DFN | CODE | SAMP | KBD | VAR | CITE | ABBR | ACRONYM
  • ...and so on

They will, in turn, have other nested elements.

You can repeat the operation for other HTML DTDs.

To know how DTDs nesting rules work, I suggest to read a tutorial.

查看更多
登录 后发表回答