Home  >  Article  >  Web Front-end  >  How to set the indentation of the first line of html

How to set the indentation of the first line of html

王林
王林Original
2021-06-21 14:12:3012670browse

The way to set the indentation of the first line of HTML is to add the text-indent attribute to the paragraph text and set a reasonable indentation value, such as [p {text-indent:50px;}].

How to set the indentation of the first line of html

The operating environment of this article: windows10 system, html 5, thinkpad t480 computer.

We can use the text-indent attribute to achieve the indentation effect of the first line of text. It is very simple to use. There may be many friends who don’t know much about the text-indent attribute. Let’s take a look at the text-indent attribute.

The text-indent attribute specifies the indentation of the first line of text in a text block.

Attribute value:

  • length defines fixed indentation. Default value: 0.

  • % Defines the indent based on a percentage of the width of the parent element.

  • #inherit Specifies that the value of the text-indent attribute should be inherited from the parent element.

Code example:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文网(php.cn)</title> 
<style>
p {text-indent:50px;}
</style>
</head>
<body>

<p>In my younger and more vulnerable years my father gave me some advice that I&#39;ve been turning over in my mind ever since. </p>

</body>
</html>

The running effect is as shown below:

How to set the indentation of the first line of html

Related recommendations: html video tutorial

The above is the detailed content of How to set the indentation of the first line of html. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn