What elements can a span tag contain in HTML5?

后端 未结 1 1429
日久生厌
日久生厌 2020-12-01 09:18

So I have been a CLI or Cron developer in PHP for most my career and now I am learning why I did not like UI work in school ;) I am dealing with HTML5 validation here and I

相关标签:
1条回答
  • 2020-12-01 09:44

    Only inline elements may be contained within inline elements. span is an inline element. So, tags like a, img, sup, etc. can go within a span, but block level elements like div and p cannot.

    UPDATE

    In reality, different elements which default to inline display behave differently. Some "inline" elements may allow block elements (a for example), while others don't (like span).

    If you're interested in what an HTML tag may contain, your most official source is the WHATWG page on HTML elements. You can check any HTML element and see what content is permitted (see 'Content Model' for each element):

    http://www.whatwg.org/specs/web-apps/current-work/multipage/#auto-toc-4

    Here's the definition of the span tag, which indicates that only 'phrasing' content is allowed.

    http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-span-element

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