The text-indent
property in CSS helps you control the indentation of the first line of a paragraph. This is useful for creating a polished and readable layout.
p {
text-indent: 50px;
}
p {
text-indent: 10%;
}
p {
text-indent: -20px;
}
p {
text-indent: 0;
}
Here’s how these styles look in action:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Text Indent Example on codersmile.com</title>
<style>
.basic-indent {
text-indent: 50px;
}
.percentage-indent {
text-indent: 10%;
}
.negative-indent {
text-indent: -20px;
}
.no-indent {
text-indent: 0;
}
</style>
</head>
<body>
<p class="basic-indent">This paragraph has a basic indent of 50 pixels.</p>
<p class="percentage-indent">This paragraph has an indent of 10% of the container's width.</p>
<p class="negative-indent">This paragraph has a negative indent, creating a hanging indent effect.</p>
<p class="no-indent">This paragraph has no indent.</p>
</body>
</html>