zl程序教程

您现在的位置是:首页 >  工具

当前栏目

HTML span标签学习笔记

笔记HTML学习 标签 Span
2023-09-14 09:02:57 时间

网址:

https://www.w3schools.com/tags/tag_span.asp

行内元素

span是inline(行内)元素。

设置宽高无效:


设置padding有效:

一小格是5px,两小格是10px.

  • padding设置上下左右都有效,即会撑大空间;
  • 行内元素尺寸 由内含的内容决定

块元素

例子是div

浅绿色的就是margin区域:

设置高度和宽度起作用。

一个典型的span用法:

<!DOCTYPE html>
<html>
<body>

<h1>The span element</h1>

<p>My mother has <span style="color:blue;font-weight:bold">blue</span> eyes and my father has <span style="color:darkolivegreen;font-weight:bold">dark green</span> eyes.</p>

</body>
</html>

The span tag is an inline container used to mark up a part of a text, or a part of a document.

The span tag is much like the div element, but div is a block-level element and span is an inline element.

和div作用类似,但span是inline元素,div是block元素。

何时应该使用span?

It should be used only when no other semantic element is appropriate.

更多Jerry的原创文章,尽在:“汪子熙”: