HTML缩进教程及示例

在向HTML网页添加文本时,样式很重要。关于HTML中的文本,有很多不同的样式选项。缩进是另一个有用的样式,在这里文本的起始位置可以稍微改变一下,这会使它看起来很优雅。在本教程中,我们将学习使用HTML标记、CSS属性和一些技巧以不同的方式设置样式类型和方式。

【张馨予推荐】澳洲life space益生菌大人成年益生菌食品调理肠胃
【0元入会】【咨询客服有惊喜】 | 月销量10000件
券后229-30=199元
原价¥320

淘口令:

¥CZzJ2XS0asW¥
 

缩进类型

在开始识别之前,我们需要学习缩进类型。即使缩进通常用作文本或段落的第一行,我们也可以缩进整个文本块或段落。

块级缩进

块级缩进将缩进整个块文本或段落。这在以下情况下很有用

Block Level Indent
块级缩进

单行缩进

一行只缩进一行,其他行如果在同一块或段落中,则为标准格式。

Single Line Indenting
单行缩进

用不间断空格缩进HTML标记

HTML提供了不间断的空格,可以在文本中插入空格。我们可以使用多个不间断空格来创建如下所示的缩进。

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.       It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum
Indent with Non-Breaking Spaces HTML Tag
用不间断空格缩进HTML标记

缩进CSS文本缩进第一行

CSS提供 text-indent 属性只能缩进第一行。我们可以用 text-indent 属性以不同的方式使用CSS,如内联或外部CSS文件。文本缩进属性接受缩进大小作为像素。在本例中,我们将行缩进为80像素。

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Indent with CSS text-indent The First Line
缩进CSS文本缩进第一行

用CSS margin left属性缩进块文本

margin-left 是一个CSS属性,用于为给定的HTML元素创建左边距。我们可以使用margin left属性创建一个看起来像缩进的边距。在本例中,我们将创建大约40px的边距。

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Indent with CSS margin-left Attribute The Block Text
用CSS margin left属性缩进块文本

用Blockquote HTML标记缩进

blockquote 是一个HTML标记,主要用于以格式化的方式提供一些报价文本。但是通过使用blockquote标记属性,我们可以缩进单行或块。

单行缩进

1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been

the industry's standard dummy text ever since the 1500s, when an unknown printer took
Indent with Blockquote HTML Tag
用Blockquote HTML标记缩进

块缩进

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Indent with Blockquote HTML Tag
用Blockquote HTML标记缩进

用预先格式化的HTML标记缩进

HTML提供了预格式化的标记,其中预格式化文本的内容将与其提供的内容相同。这将使我们能够更改并为缩进提供不会被HTML更改的空间。

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
 It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Indent with Preformatted HTML Tag
用预先格式化的HTML标记缩进

相关文章: 如何在HTML中居中放置表格?

© 版权声明
THE END
喜欢就支持一下吧,技术咨询可以联系QQ407933975
点赞0 分享