在本文中,我们将讨论在 HTML 文档中缩进文本的各种方法。文本缩进用于设置块中文本行前的空白长度。它通常标志着一个段落的开始。
文本缩进有两种常见的方法:
方法 1:使用margin-left 属性:此属性用于在元素的左侧添加边距。它可用于通过以合适的长度单位或百分比指定所需的空间来添加所需的缩进。
示例:本示例使用 margin-left 属性来缩进整个文本块。
HTML
Welcome To GFG
We provide a variety of services
for you to learn, thrive and also
have fun! Free Tutorials, Millions
of Articles, Live, Online and
Classroom Courses ,Frequent Coding
Competitions ,Webinars by Industry
Experts, Internship opportunities
and Job Opportunities.
HTML
Welcome To GFG
We provide a variety of services
for you to learn, thrive and also
have fun! Free Tutorials, Millions
of Articles, Live, Online and
Classroom Courses ,Frequent Coding
Competitions ,Webinars by Industry
Experts, Internship opportunities
and Job Opportunities.
输出:
方法 2:使用text-indent 属性:此属性用于设置段落中第一行文本之前的空间量。它可以根据需要以长度单位或百分比指定。
示例:在此示例中,段落的第一行使用 text-indent 属性缩进。
HTML
Welcome To GFG
We provide a variety of services
for you to learn, thrive and also
have fun! Free Tutorials, Millions
of Articles, Live, Online and
Classroom Courses ,Frequent Coding
Competitions ,Webinars by Industry
Experts, Internship opportunities
and Job Opportunities.
输出: