Home >Web Front-end >CSS Tutorial >How to indent a paragraph in css
In css, you can use the text-indent attribute to indent a paragraph of text. You only need to add the "text-indent: indent value;" style to the paragraph element. The text-indent attribute can set the indent of the first line of text in the text block, allowing negative values; if the value is a negative number, the first line will be left indented.
The operating environment of this tutorial: windows7 system, css1&&html5 version, Dell G3 computer.
Tutorial recommendation: css video tutorial
CSS Paragraph Indent
If you want to modify the default style of the paragraph element, let To indent paragraphs, you can use the text-indent attribute.
The text-indent attribute specifies the indentation of the first line of text in a text block. Negative values are allowed; if the value is negative, the first line is left indented.
Attribute value:
length defines fixed indentation. Default value: 0.
% Defines the indent based on a percentage of the width of the parent element.
Example: The p element with
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style type="text/css"> p{width: 200px;border: 1px solid red;} .text-indent{text-indent:2em;} </style> </head> <body> <p>测试文本!测试文本!测试文本!测试文本!测试文本!</p> <p class="text-indent">测试文本!测试文本!测试文本!测试文本!测试文本!</p> </body> </html>
class as text-indent will be indented by the length of 2 fonts.
Rendering:
For more programming-related knowledge, please visit: Programming Teaching! !
The above is the detailed content of How to indent a paragraph in css. For more information, please follow other related articles on the PHP Chinese website!