Computer >> Computer tutorials >  >> Programming >> CSS

Text Indentation using CSS


For text indentation, use the text-indent property in CSS. This is for the indentation of the first line in a paragraph.

Example

Let us now see an example −

<!DOCTYPE html>
<html>
<head>
<style>
div {
   text-indent: 30px;
}
</style>
</head>
<body>
<h1>Demo Heading</h1>
<div>
<p>This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text.
</p>
</div>
</body>
</html>

Output

Text Indentation using CSS

Example

Let us now see another example −

<!DOCTYPE html>
<html>
<head>
<style>
div {
   text-indent: 15em;
}
</style>
</head>
<body>
<h1>Demo Heading</h1>
<div>
<p>This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text.
</p>
</div>
</body>
</html>

Output

Text Indentation using CSS