From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/html/element/span/index.html | 96 ++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 files/zh-cn/web/html/element/span/index.html (limited to 'files/zh-cn/web/html/element/span') 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: +slug: Web/HTML/Element/span +tags: + - HTML + - span + - 元素 + - 流内容 + - 行内元素 +translation_of: Web/HTML/Element/span +--- +
{{HTMLRef}}
+ +

HTML <span> 元素是短语内容的通用行内容器,并没有任何特殊语义。可以使用它来编组元素以达到某种样式意图(通过使用类或者Id属性),或者这些元素有着共同的属性,比如lang。应该在没有其他合适的语义元素时才使用它。<span> 与 {{HTMLElement("div")}} 元素很相似,但 {{HTMLElement("div")}} 是一个 块元素<span> 则是 行内元素 .

+ +
{{EmbedInteractiveExample("pages/tabbed/span.html", "tabbed-shorter")}}
+ + + + + +

属性

+ +

该元素仅包含 全局属性

+ +

例 1

+ +
<p><span>一些文字</span></p>
+ +

结果

+ +

{{EmbedLiveSample('Example1')}}

+ +

例 2

+ +
<li><span>
+    <a href="portfolio.html" target="_blank">See my portfolio</a>
+</span></li>
+
+ +

CSS

+ +
li span {
+  background: gold;
+ }
+ +

结果

+ +

{{EmbedLiveSample('Example2')}}

+ +

规范

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
规范状态注释
{{SpecName('HTML WHATWG', 'text-level-semantics.html#the-span-element', '<span>')}}{{Spec2('HTML WHATWG')}}
{{SpecName('HTML5 W3C', 'text-level-semantics.html#the-span-element', '<span>')}}{{Spec2('HTML5 W3C')}} +

{{domxref("HTMLSpanElement")}} (在 {{glossary("HTML5")}}, 之前是 {{domxref("HTMLElement")}})

+
{{SpecName('HTML4.01', 'struct/global.html#edef-SPAN', '<span>')}}{{Spec2('HTML4.01')}}
+ +

浏览器兼容性

+ +

{{Compat("html.elements.span")}}

+ +

参见

+ + -- cgit v1.2.3-54-g00ecf