×

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

Pairwise swap elements of a given linked list

Pairwise swap elements of a given linked list In this problem, we have given a linked list, and we need to pairwise swap elements of the given linked list. Example:                                     Input:1 ->3...

4 minutes read.

Function to Insert a Node in a Binary Search Tree

Implementation // writing C++ code that will help us in implementing the insertion operation in a binary search tree. #include <bits/stdc++.h> using namespace std; // creating a new binary search tree node struct __nod { int...

8 minutes read.

Data Structure Infix to Postfix Conversion

Infix to Postfix Conversion The infix expression is easy to read and write by humans. In present time, we use the infix expression in our daily life but the computers are...

4 minutes read.

Top view of binary tree

We know that a binary tree is a kind of tree that helps us organize our tree and that it is a kind of non-linear info structure that at least...

4 minutes read.

Delete the Middle element of the Linked List in C

Delete the Middle element of the Linked List in C This article has given a singly linked list and will delete the middle element of the given linked list. Example:  The given...

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.

Buffer overflow attack with examples

You have undoubtedly faced the term buffer overflow in your programming journey. Many times it occurs when we try to run a piece of code with user input, but it...

4 minutes read.

Segregate Even and Odd nodes in a Linked List

Segregate even and odd nodes in a Linked List In this problem, we have given a linked list with integer numbers. We need to modify the given linked list in such...

4 minutes read.

What Is Dfs Algorithm in Data Structures

DFS stands for Depth First Search. Generally, it is a repetitive or decidable type of algorithm which is basically used in identifying all the vertices or nodes of a graph...

5 minutes read.

Delete a Node without head pointer from the linked list

Delete a Node without head pointer from the linked list This article will explain how to delete a node without a head pointer from the linked list. We have given a...

2 minutes read.

Vertical Order Traversal of Binary Tree

Implementation #include <iostream> #include <vector> #include <map> using namespace std; // representing the primary model of a binary tree node. struct _nod { int ky; _nod *Lft, *Rt; }; // establishing a new function representing the new binary tree node. struct _nod*...

5 minutes read.

Applications of Different Linked Lists in Data Structure

What is a Linked list? A linked list is a data structure that consists of a sequence of elements, where each containing a reference or ("link") to the next element in...

5 minutes read.

Identical Linked Lists

Identical Linked Lists In this problem, we have given two linked lists, and we need to check whether the given linked lists are identical or not. Identical means they have the...

4 minutes read.

Given a Binary Tree, Print the Pre-order Traversal in Recursive

Implementation #include <stdio.h> #include <stdlib.h>   /* Creating a binary tree node that consists of some data along with the pointer to the left and right child.  */ struct __nod {     int record;     struct...

4 minutes read.

Burning binary tree

Burn the Binary tree starting from the target node You have given a binary tree and a target node value. Now you have to burn the tree from target node. You...

4 minutes read.

Post-order traversal in a binary tree

We all know that postorder is a form of tree traversal to visit the tree's nodes, and it helps us reach out to the tree's nodes. Postorder means visiting the...

4 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.

Asynchronous advantage actor-critic (A3C) Algorithm

The Asynchronous advantage actor-critic (A3C) Algorithm is one of the latest algorithms developed by the Artificial Intelligence division, Deep Mind at Google. It is used for the Deep Reinforcement Learning...

3 minutes read.

Box Stacking Problem

Stacking of boxes depending on their base You have been given n different boxes. These boxes will have different heights, widths, and depths. You have to stack all these boxes in...

4 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.