×

CSS Text-indent

Text-indent

The Text-indent property of CSS is used to set any first line’s indentation inside a text’s block. It describes the horizontal space amount that puts establish before the text line.

It also allows the negative values in CSS. When the negative values are specified, the first line’s indentation will be to the life side.

Syntax:

text-indent: length | inherit | initial;  

Property Values

length: The length specified above is used to set the fixed indentation along with some units like px, em, pt, cm, and many others. It has a default value of 0. Also, it permits negative values. If its values are negative, then the first line’s indentation will be on the left side.

percentage: It describes the amount inside the space within the width percentage of any containing block.

initial: It can be used to set the attribute to its default attribute. This property value contains two other experimental attributes, which are explained below. The following two values are not supported inside the browsers.

hanging: This value is experimental and unofficial value. It inverts any indented line. Except for the first line, it can indent all the lines. The bibliographies are usually mentioned along with this value, in which any first line will be with a left-hand side margin, and other contents are indented.

each-line: These property values are also the experimental values. This value can influence all the lines and the first line afterward, the affected line break (with the use of <br>).

Example:

In the following example, we apply the CSS text-indent property along with some length values like cm, em, and px. Also, we are using the CSS text-align: justify; property to find the exceptional results.

<!DOCTYPE html>
<html>
<head>
<title> Text-indent Property </title>
<style>
div
{
 font-size: 20px;
 width: 500px;
 height: 200px;
 text-align: justify;
}
.exppx
{
 text-indent: 100px;
}
.expem
{
 text-indent: -5em;
}
expcm
{
 text-indent: 7cm;
}
</style>
</head>
<body>
<center>
<h1> Text-indent CSS property Example </h1>
<h2> text-indent: 100px; </h2>
<div class= "exppx">
Hello, welcome to this page. This site is made so that a lot of students may study various technologies related to computer science easily. This site is always giving an in-depth and easy tutorial on multiple technologies. Everyone can't be perfect in this entire world, and everything can't be perfect. But we must try to be improved.
</div>
<h2> text-indent: -5em; </h2>
<div class= "expem">
Hello, welcome to this page. This site is made so that a lot of students may study various technologies related to computer science easily. This site is always giving an in-depth and easy tutorial on multiple technologies. Everyone can't be perfect in this entire world, and everything can't be perfect. But we must try to be improved.
</div>
<h2> text-indent: 7cm; </h2>
<div class= "expcm">
Hello, welcome to this page. This site is made so that a lot of students may study various technologies related to computer science easily. This site is always giving an in-depth and easy tutorial on multiple technologies. Everyone can't be perfect in this entire world, and everything can't be perfect. But we must try to be improved.
</div>
</center>
</body>
</html>

Output:

CSS Text-indent

Example:

Let’s take another illustration with the use of some percentage values.

<!DOCTYPE html>
<html>
<head>
<title> Text-indent Property </title>
<style>
div
{
 font-size: 20px;
 width: 500px;
 height: 200px;
 text-align: justify;
}
.expper
{
 text-indent: 60%;
}
</style>
</head>
<body>
<center>
<h1> Text-indent CSS property Example </h1>
<h2> text-indent: 60%; </h2>
<div class= "expper">
Hello, welcome to this page. This site is made so that a lot of students may study various technologies related to computer science easily. This site is always giving an in-depth and easy tutorial on multiple technologies. Everyone can't be perfect in this entire world, and everything can't be perfect. But we must try to be improved.
</div>
</center>
</body>
</html>

Output:

CSS Text-indent

Related Topics

Extended Binary Tree

An extended binary tree is a binary tree in which all the NILL subtrees present mainly in the original trees are exchanged with the special nodes that are primarily known...

3 minutes read.

Perfect Binary Tree

Complete binary trees are an important and general topic in the concept – of tree data structures. Before discussing a complete binary tree, we need to know the concept of...

4 minutes read.

Insertion sort

Insertion sort is a simple sorting technique. It is best suited for small data sets, but it does not suitable for large data sets. In this technique, we pick an...

4 minutes read.

What is an AVL Tree in Data Structure?

AVL tree stands for (Adelson, Velskii, & Landis Tree) Data structure Data management is called database management. A data model is a system used to store, manage, and optimize computer resources. Data...

4 minutes read.

Cycle sort

Cycle sort is an examination arranging calculation which powers exhibit to be figured into the quantity of cycles where every one of them can be pivoted to create an arranged...

5 minutes read.

Collision Resolution Techniques

Collision Resolution Techniques Collision in hashing In this, the hash function is used to compute the index of the array.The hash value is used to store the key in the hash table,...

2 minutes read.

Traversal of binary tree

Traversal of binary tree: A node is visited only once in the traversal of the binary tree. There are three main types of traversal methods in the binary tree. In-order traversalPre-order...

3 minutes read.

Introduction to 1D-Arrays

One Dimensional Array Technical Definitions The simplest version of an Array is a One-Dimensional Array, in which the items are stored linearly and may be accessed individually by supplying the index value...

6 minutes read.

Selection Sort

In each iteration of the selection sort algorithm, the smallest item from an unsorted list is chosen and placed at the top of the unsorted list. Algorithm of Selection Sorting In order...

3 minutes read.

What is the Use of Segment Trees in Data Structure?

Segment trees Segment trees are also called statistical trees in computer science. They are a type of tree data structure. Segment trees are used to store information regarding segments and intervals....

6 minutes read.

Merge two sorted linked lists

Merge two sorted linked lists In this article, we are going to learn how to merge two linked lists. Here we have given two linked lists that are sorted in increasing...

7 minutes read.

Merge Conflicts and ways to handle them

Merge Conflicts Whenever dealing with the Git merge operations, conflicts will be the frequently occurred. When more than two developers work on the same file on different systems using Git, they...

4 minutes read.

Trim a binary search tree

Implementation //writing a C++ program will help us eliminate the keys that are out of the league.  #include<bits/stdc++.h> using namespace std; //we are now creating a binary search tree node consisting of key left...

8 minutes read.

Bubble Sort vs Merge Sort

In this article, we are going to compare two sorting techniques, Bubble sort and Merge Sort. In starting, we will first discuss the idea of sorting an array using bubble...

7 minutes read.

Advantages and Disadvantages of Linked List

Advantages of Linked List The linked list is a dynamic data structure.You can also decrease and increase the linked list at run-time. That is, you can allocate and deallocate memory at...

3 minutes read.

Bubble sort algorithm using Javascript

Sorting is a very useful technique in many algorithms and programs. Basically, sorting operations help us to arrange a set of data in a particular manner. Bubble sort is one...

3 minutes read.

Stack vs Array

Difference between Array and Stack In this article, we are going to discuss the major differences between the stack and array data structures: Array – In the data structure, the array is...

3 minutes read.

Polish Notation in Data Structures

Arithmetic Expression: An arithmetic expression is defined as several operands or data items combined using several operators. For example; a+b*(c-d) is an expression. Operands: Operands represent the data in an expression...

2 minutes read.

What is a Threaded Binary Tree?

When we consider those binary trees that are interlinked with each other, we do come across the fact that the fields present in there do consist of NULL values that...

3 minutes read.

Find out the area between two concentric circles

You have given two values of the radius of two circles. You have to find out the area between these two circles. Let's take an example - For the above diagram,...

3 minutes read.