diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/html/element/span | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/html/element/span')
-rw-r--r-- | files/zh-cn/web/html/element/span/index.html | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/files/zh-cn/web/html/element/span/index.html b/files/zh-cn/web/html/element/span/index.html new file mode 100644 index 0000000000..4470ad4e80 --- /dev/null +++ b/files/zh-cn/web/html/element/span/index.html @@ -0,0 +1,96 @@ +--- +title: <span> +slug: Web/HTML/Element/span +tags: + - HTML + - span + - 元素 + - 流内容 + - 行内元素 +translation_of: Web/HTML/Element/span +--- +<div>{{HTMLRef}}</div> + +<p><strong>HTML <code><span></code> </strong>元素是短语内容的通用行内容器,并没有任何特殊语义。可以使用它来编组元素以达到某种样式意图(通过使用类或者Id属性),或者这些元素有着共同的属性,比如<strong>lang</strong>。应该在没有其他合适的语义元素时才使用它。<code><span></code> 与 {{HTMLElement("div")}} 元素很相似,但 {{HTMLElement("div")}} 是一个 <a href="/en-US/docs/HTML/Block-level_elements">块元素</a> 而 <code><span></code> 则是 <a href="/en-US/docs/HTML/Inline_elements"> 行内元素 </a>.</p> + +<div>{{EmbedInteractiveExample("pages/tabbed/span.html", "tabbed-shorter")}}</div> + +<div class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> and send us a pull request.</div> + +<ul class="htmlelt"> + <li><dfn><a href="/en-US/docs/HTML/Content_categories" title="HTML/Content_categories">内容分类</a></dfn> <a href="/en-US/docs/HTML/Content_categories#Flow_content" title="HTML/Content categories#Flow content">流内容</a>, <a href="/en-US/docs/HTML/Content_categories#Phrasing_content" title="HTML/Content categories#Phrasing content">表述内容</a>.</li> + <li><dfn>允许的内容</dfn><a href="/zh-CN/docs/Web/Guide/HTML/Content_categories#Phrasing_content">短语元素</a></li> + <li><dfn>标签省略</dfn> 不允许,开始标签和结束标签都不能省略。</li> + <li><dfn>允许的父元素</dfn>任意可以包含 <a href="/en-US/docs/HTML/Content_categories#Phrasing_content" title="https://developer.mozilla.org/en-US/docs/HTML/Content_categories#Phrasing_content">表述内容</a> 或 <a href="/en-US/docs/HTML/Content_categories#Flow_content" title="https://developer.mozilla.org/en-US/docs/HTML/Content_categories#Flow_content">流内容</a> 的元素。</li> + <li><dfn>DOM 接口</dfn>{{domxref("HTMLSpanElement")}} (在 {{glossary("HTML5")}}, 之前是 {{domxref("HTMLElement")}})</li> +</ul> + +<h2 id="Attributes" name="Attributes">属性</h2> + +<p><span style="line-height: 21px;">该元素仅包含 </span><a href="https://developer.mozilla.org/en-US/docs/HTML/Global_attributes" style="line-height: 21px;" title="HTML/Global attributes">全局属性</a>。</p> + +<h2 id="Example1" name="Example1">例 1</h2> + +<pre class="brush:html;gutter:false notranslate"><p><span>一些文字</span></p></pre> + +<h3 id="Result1" name="Result1">结果</h3> + +<p>{{EmbedLiveSample('Example1')}}</p> + +<h2 id="Example2" name="Example2">例 2</h2> + +<pre class="brush:html;gutter:false notranslate"><li><span> + <a href="portfolio.html" target="_blank">See my portfolio</a> +</span></li> +</pre> + +<h3 id="CSS">CSS</h3> + +<pre class="brush:css notranslate; notranslate"><code>li span { + background: gold; + }</code></pre> + +<h3 id="Result2" name="Result2">结果</h3> + +<p>{{EmbedLiveSample('Example2')}}</p> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">规范</th> + <th scope="col">状态</th> + <th scope="col">注释</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('HTML WHATWG', 'text-level-semantics.html#the-span-element', '<span>')}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td></td> + </tr> + <tr> + <td>{{SpecName('HTML5 W3C', 'text-level-semantics.html#the-span-element', '<span>')}}</td> + <td>{{Spec2('HTML5 W3C')}}</td> + <td> + <p>{{domxref("HTMLSpanElement")}} (在 {{glossary("HTML5")}}, 之前是 {{domxref("HTMLElement")}})</p> + </td> + </tr> + <tr> + <td>{{SpecName('HTML4.01', 'struct/global.html#edef-SPAN', '<span>')}}</td> + <td>{{Spec2('HTML4.01')}}</td> + <td></td> + </tr> + </tbody> +</table> + +<h2 id="See_also" name="See_also">浏览器兼容性</h2> + +<p>{{Compat("html.elements.span")}}</p> + +<h2 id="See_also" name="See_also">参见</h2> + +<ul> + <li>HTML {{HTMLElement("div")}} 元素</li> +</ul> |