Is it ok to have an `` inside another ``?

前端 未结 4 1406
小鲜肉
小鲜肉 2020-12-20 11:22

If I had a link to another page, and another link was put inside it, would that be ok to do? Is it allowed in HTML5 and if so, which browsers support it?

Trying this

相关标签:
4条回答
  • 2020-12-20 11:39

    According to the W3C specification for links HTML5: No.

    Content model:
    Transparent, but there must be no interactive content descendant.

    0 讨论(0)
  • 2020-12-20 11:44

    According to the W3C specification for links HTML4: No.

    Links and anchors defined by the A element must not be nested; an A element must not contain any other A elements.

    Or, in HTML5 spec:

    Links are a conceptual construct, created by a, area, and link elements, that represent a connection between two resources.

    0 讨论(0)
  • 2020-12-20 11:44

    No, you cannot nest a elements in HTML 4 or 5. The key part of the spec that clarifies this is that when an a is a link, it is interactive content, and the content model of the a is

    Transparent, but there must be no interactive content descendent

    Reference

    0 讨论(0)
  • 2020-12-20 11:48

    Even on HTML5 it's not allowed...

    See here: HTML5 draft at W3C

    The a element may be wrapped around entire paragraphs, lists, tables, and so forth, even entire sections, so long as there is no interactive content within (e.g. buttons or other links).

    0 讨论(0)
提交回复
热议问题