CSS Indent Paragraph
In this article, we will learn how to space a paragraph in CSS. If you want to add some indentation (space) to the beginning of the paragraph, we should use the CSS “text-indent” property.
If you add space like this:
<p> Cascading Style Sheet</p>
A space will not be added at the beginning of the paragraph because the browser will remove all extra spaces.
How to use Text indent property
<!DOCTYPE html>
<html>
<head>
<title>Text indentation</title>
</head>
<body>
<p style="text-indent: 20px;">Cascading Style Sheet</p>
</body>
</html>
Output:
Step:
- In the above code, we have written the basic structure of HTML.
- Then we create a <p> tag with some text in the body section.
- We want to add some indent (space) to the beginning of the paragraph, So we use the “text-indent” property and give the value as “20px“.
- We can give value as px, em, pt, etc.
- See the above output the text is displayed with some space at the beginning of the paragraph.