开发者

HTML <inline> can contain another <inline> element?

Sounds like that is possible, per W3C am able to validate the following HTML code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
   <title>Inline can another inline?</title>
</head>
<body>
   <div>
      <span>some text <span>comes here</span>.<开发者_如何学C;/span>
    </div>
</body>
</html>

Is that means an inline can contain another inline? Am confused, so long I thought only block-level elements can contain another block-level or inline elements. Also thought inline elements can contain only text. Can any one give some theory here with W3C reference or some reference, please? Thanks.


Yes, some inline elements are allowed to contain inline elements. Here’s the definition of the parameter entity inline:

<!ENTITY % inline "#PCDATA | %fontstyle; | %phrase; | %special; | %formctrl;">

The content model for the elements described by the parameter entities fontstyle and phrase are then defined as follows:

<!ELEMENT (%fontstyle;|%phrase;) - - (%inline;)*>

That means all elements described by fontstyle and phrase can contain inline elements.

The other inline elements that are described by special and formctrl except the empty elements BR, IMG, INPUT, and except the elements SCRIPT, SELECT, and TEXTAREA (i.e. A, OBJECT, MAP, Q, SUB, SUP, SPAN, BDO, LABEL, and BUTTON) may contain inline elements (with some additional restrictions for LABEL, and BUTTON).


That's correct. It's described in HTML spec chapter 7 The global structure of an HTML document:

7.5.3 Block-level and inline elements

Content model - Generally, block-level elements may contain inline elements and other block-level elements. Generally, inline elements may contain only data and other inline elements. Inherent in this structural distinction is the idea that block elements create "larger" structures than inline elements.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜